Here is the design of the form:
using System;
using System.Windows.Forms;
using SpeechLib;
namespace SpeechDemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//get installed voices
SpVoice voice = new SpVoice();
foreach (var item in voice.GetVoices())
{
comboBox1.Items.Add(((ISpeechObjectToken)item).GetDescription());
}
}
private void btnSpeakPhonems_Click(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex > 0)
{
SpVoice voice = new SpVoice();
voice.Voice = voice.GetVoices().Item(comboBox1.SelectedIndex);
voice.Speak("<pron sym=\"ang 1 zang 1\">变脏</pron>", SpeechVoiceSpeakFlags.SVSFlagsAsync);
}
}
}
}
Edit:
in SpeechSynthesizer pron => phoneme and sym => ph . here is code works fine with SpeechSynthesizer :
private void button1_Click(object sender, EventArgs e)
{
var cu = CultureInfo.GetCultureInfo("zh-CN");
SpeechSynthesizer sp = new SpeechSynthesizer();
var voices = sp.GetInstalledVoices(cu);
sp.SelectVoice(voices[0].VoiceInfo.Name);
string s = "<?xml version=\"1.0\"?> <speak version=\"1.0\" xml:lang=\"zh-CN\"><phoneme ph=\"ang 1 zang 1\">变</phoneme></speak>";
sp.SpeakSsml(s);
}