语音合成器无法select安装语音

Speech synthesizer can't select installed voice

我有以下程序:

        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); 为了让 Hazel 阅读这句话,我得到以下 SystemArgumentException:

{"Cannot set voice. No matching voice is installed or the voice was disabled."}

并且所有语音都已启用。 我已经安装了以下东西:

  1. Microsoft 语音平台 - 运行时(版本 11)
  2. Microsoft 语音平台 - 软件开发工具包 (SDK)(版本 11)
  3. 以及打印列表中显示的其他语言。

并且我按照 this 指南让我的 OS (win7x64) 识别我的语言。 我怎么只能用安娜?

我成功了。这就是我所做的。 我用错了SpeechSynthesizer 我用了System.Speech.SpeechSynthesizer 而不是 Microsoft.Speech.Synthesis。您必须添加位于 C:\Program Files\Microsoft SDKs\Speech\v11.0\Assembly

Speech.dll 参考

然后我可以使用 Hazel、Harmonie 和 Hanna,但不再使用 Anna(反正我不需要她)。

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