I\'m performing some text-to-speech and I\'d like to specify some special pronunciations in a lexicon file. I have ran MSDN\'s AddLexicon example verbatim, and it speaks the
You can use System.Speech.Synthesis.SpeechSynthesizer.SpeakSsml() instead of a lexicon.
This code changes pronunciation of "blue" to "yellow" and "dog" to "fish".
SpeechSynthesizer synth = new SpeechSynthesizer();
string text = "This is a blue dog";
Dictionary phonemeDictionary = new Dictionary { { "blue", "jelow" }, { "dog", "fyʃ" } };
foreach (var element in phonemeDictionary)
{
text = text.Replace(element.Key, "" + element.Key + " ");
}
text = "" + text + " ";
synth.SpeakSsml(text);