我有以下节目:
SpeechSynthesizer synth = new SpeechSynthesizer();
List<InstalledVoice> installedVoices = new List<InstalledVoice>();
foreach (InstalledVoice voice in synth.GetInstalledVoices())
{
installedVoices.Add(voice);
Console.WriteLine(voice.VoiceInfo.Name);
}
synth.SelectVoice(installedVoices[1].VoiceInfo.Name);
synth.Speak("This is in English");已安装的声音的输出如下:
Microsoft Anna
Microsoft Server Speech Text to Speech Voice (en-GB, Hazel)
Microsoft Server Speech Text to Speech Voice (fr-CA, Harmonie)
Microsoft Server Speech Text to Speech Voice (nl-NL, Hanna)当我使用synth.SelectVoice(installedVoices[0].VoiceInfo.Name);运行程序时,它没有任何问题。当使用synth.SelectVoice(installedVoices[1].VoiceInfo.Name);运行它以让黑兹尔读这个句子时,我得到以下SystemArgumentException
{"Cannot set voice. No matching voice is installed or the voice was disabled."}所有的声音都被激活了。我安装了以下设备:
我遵循this指南,让我的语言被操作系统(win7x64)所认可。为什么我只能用安娜?
发布于 2015-11-23 10:53:55
我让它成功了。我就是这么做的。我使用了错误的SpeechSynthesizer,我使用了System.Speech.SpeechSynthesizer而不是Microsoft.Speech.Synthesis。您必须添加位于C:\Program Files\Microsoft SDKs\Speech\v11.0\Assembly的C:\Program Files\Microsoft SDKs\Speech\v11.0\Assembly引用
然后,我可以使用哈泽尔,哈米和汉娜,但安娜不再(反正我不需要她)。
另外,不要忘记将您的项目构建设置为x64,因为SDK是x64,或者安装x86 SDK和运行时。
https://stackoverflow.com/questions/33867495
复制相似问题