c# - SpeechSynthesizer.SelectVoice() 失败并显示 "No matching voice is installed or the voice was disabled"

标签 c# text-to-speech speechsynthesizer microsoft-speech-platform

我正在修改Scott HanselmanBabySmash支持其他语言的代码。

  1. 我按照 these steps 安装了语音平台和新语言.
  2. 该语言现在显示在注册表中:

    enter image description here

  3. 现在可以通过 Windows 选择和播放语言:

    enter image description here

  4. System.Speech.Synthesis.SpeechSynthesizer.GetInstalledVoices()现在返回声音。

  5. 但是SelectVoice()下面的代码中会抛出错误“System.ArgumentException:无法设置语音。未安装匹配的语音或语音已禁用。”
string phrase = null;
SpeechSynthesizer speech = new SpeechSynthesizer();
CultureInfo keyboardCulture = System.Windows.Forms.InputLanguage.CurrentInputLanguage.Culture;
InstalledVoice neededVoice = speech.GetInstalledVoices(keyboardCulture).FirstOrDefault();
if (neededVoice == null)
{
    phrase = "Unsupported Language";
}
else if (!neededVoice.Enabled)
{
    phrase = "Voice Disabled";
}
else
{
    speech.SelectVoice(neededVoice.VoiceInfo.Name);
}

speech.Speak(phrase);
  • 我已尝试升级到 C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Speech.dll .

  • 我已经verified that the versionsMicrosoft.Speech.dll和语言包匹配。

    enter image description here

  • 此代码适用于我已安装的默认语音。

  • 无奈之下,我什至尝试调用 System.Speech.Internal.Synthesis.VoiceSynthesis.GetVoice()直接通过反射,但同样的错误。

  • 我将非常感谢您提供的任何帮助!谢谢。

    最佳答案

    哈哈我觉得很特别:this post on Python实际上解决了我的问题:构建配置平台需要是x64,而不是任何CPU!

    关于c# - SpeechSynthesizer.SelectVoice() 失败并显示 "No matching voice is installed or the voice was disabled",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34776593/

    相关文章:

    java - 运行时错误 - JSAPI HelloWorld 程序

    node.js - 如何更改 Node 模块 "say"的音频输出设备

    java - 无法与 TTS 同步在 recyclerVIew 中显示 imageView

    c# - C# 中的 SpeechSynthesizer 创建具有 22kHz 的 wav...需要为 16kHz

    C# 字符串处理如何从字符串中获取路径和参数

    iphone - 生成错误 : expected a property attribute before 'unsafe_unretained'

    vb.net - SpeechSynthesizer.SpeakAsyncCancelAll() 不会取消

    c# - 定时器的最大值

    c# - System.Drawing 对于 2D 游戏编程来说足够快吗?

    C# - 通过进程名称的一部分终止进程