SpeechSynthesizer.SelectVoice()与&QUOT失败是没有安装匹配的语音或声音被禁用" [英] SpeechSynthesizer.SelectVoice() Fails with "No matching voice is installed or the voice was disabled"

查看:5289
本文介绍了SpeechSynthesizer.SelectVoice()与&QUOT失败是没有安装匹配的语音或声音被禁用"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我修改斯科特Hanselman的的的 BabySmash 代码来支持其他语言。




  1. 我安装了语音平台和一个新的每这些步骤。

  2. 语言现在显示在注册表中:




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




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


  5. 然而 SelectVoice()下面的代码中引发错误的System.ArgumentException:无法设置的声音。没有匹配的声音安装或声音被禁用。



<预类=郎-CS prettyprint-覆盖> 串词= NULL;
SpeechSynthesizer讲话=新SpeechSynthesizer();
CultureInfo的keyboardCulture = System.Windows.Forms.InputLanguage.CurrentInputLanguage.Culture;
InstalledVoice neededVoice =讲话。 GetInstalledVoices(keyboardCulture).FirstOrDefault();
如果(neededVoice == NULL)
{
语句=不支持的语言;
}!
,否则如果(neededVoice .Enabled)
{
语句=语音已禁用;
}
,否则
{
speech.SelectVoice(neededVoice.VoiceInfo.Name);
}

speech.Speak(短语);




  • 我试过升级到 C:\Program文件(x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\ 。v4.6.1\System.Speech.dll


  • 我已经的证实,该版本 Microsoft.Speech.dll 和语言包匹配




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


  • 在绝望中,我甚至试图调用 System.Speech.Internal.Synthesis.VoiceSynthesis.GetVoice()直接通过反射,但完全相同的错误。




  • 我将不胜感激任何帮助,您可以提供!谢谢你。


    解决方案

    另一种解决方案是安装(64)位的Microsoft Speech SDK平台和Microsoft服务器语音平台运行时的版本。我认为你已经安装了的(86)位和plataform尝试(64)位阅读。



    我有同样的问题,你但对相反,这工作对我!


    I am modifying Scott Hanselman's BabySmash code to support other languages.

    1. I installed the speech platform and a new language per these steps.
    2. The language now shows up in the registry:

    3. The language can now be selected and played by Windows:

    4. System.Speech.Synthesis.SpeechSynthesizer.GetInstalledVoices() now returns the voice.

    5. However SelectVoice() in the code below throws the error "System.ArgumentException: Cannot set voice. No matching voice is installed or the voice was disabled."

    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);
    

    1. I've tried upgrading to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Speech.dll.

    2. I've verified that the versions of Microsoft.Speech.dll and the language pack match.

    3. This code works for the default voices I've already had installed.

    4. In desperation, I've even tried invoking System.Speech.Internal.Synthesis.VoiceSynthesis.GetVoice() directly through reflection, but same exact error.

    I would greatly appreciate any help you can provide! Thanks.

    解决方案

    Another solution is to install (x64) bits version of Microsoft Speech Platform SDK and Microsoft Server Speech Platform Runtime. I think that you had installed (x86) bits of both and the plataform try to read it in (x64) bits.

    I had the same problem that you but on the contrary and this works to me!

    这篇关于SpeechSynthesizer.SelectVoice()与&QUOT失败是没有安装匹配的语音或声音被禁用&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆