2015-11-23 63 views
0

我有以下程序:语音合成,无法选择安装语音

 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."} 

而且所有的声音都启用。 我已经安装了以下几件事:

  1. 微软语音平台 - 运行时(第11版)
  2. 微软语音平台 - 软件开发工具包(SDK)(第11版)
  3. 而其他语言所看到的打印清单。

而且我也跟着this指导让我的语言我的OS(win7x64)的认可。 我怎么只能使用安娜?

回答

3

我使它工作。这就是我所做的。 我用错了SpeechSynthesizer我用System.Speech.SpeechSynthesizer 而不是Microsoft.Speech.Synthesis。你必须添加Speech.dll参考这是C:\Program Files\Microsoft SDKs\Speech\v11.0\Assembly

然后我可以使用淡褐色,和谐和汉娜,但安娜不再(我不需要她反正)。

另外,不要忘了将项目构建设置为x64,因为SDK是x64或安装x86 SDK和运行时。