SpeechSynthesizer无法获得所有已安装的语音3

时间:2018-08-12 18:54:53

标签: c# .net visual-studio-2017 windows-10 text-to-speech

我在区域和语言下使用“添加语言”添加了许多声音。这些出现在“语音语音转换”下。 (我正在使用Windows 10)

我想在我的应用中将它们与SpeechSynthesizer中的System.Speech.Synthesis类一起使用。

在我的应用程序中列出可用语音时,只会显示一些实际可用语音:

static void Main()
{
    SpeechSynthesizer speech = new SpeechSynthesizer();

    ReadOnlyCollection<InstalledVoice> voices = speech.GetInstalledVoices();
    if (File.Exists("available_voices.txt"))
    {
        File.WriteAllText("available_voices.txt", string.Empty);
    }
    using (StreamWriter sw = File.AppendText("available_voices.txt"))
    {
        foreach (InstalledVoice voice in voices)
        {                 
            sw.WriteLine(voice.VoiceInfo.Name);                           
        }
    }
}

仅在available_voices.txt中列出以下声音:

Microsoft David Desktop
Microsoft Hazel Desktop
Microsoft Zira Desktop
Microsoft Irina Desktop

但是在设置中的“文本到语音”下,还有更多内容,例如Microsoft GeorgeMicrosoft Mark

此处接受的答案: SpeechSynthesizer doesn't get all installed voices 建议将平台更改为x86。我试过了,但没有看到任何变化。

此答案: SpeechSynthesizer doesn't get all installed voices 2 由于System.Speech.Synthesis中的错误,建议使用.NET v4.5。我的目标是.NET Framework 4.5,但我仍然只能检索4种声音。

我链接的问题中没有一个答案可以帮助我解决问题,所以我再次提出问题。感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

我通过安装其他来源的声音并获得Microsoft Speech Platform-Runtime(版本11

)解决了该问题

答案 1 :(得分:1)

尝试了所有已发布的解决方案后,我通过编辑注册表解决了该问题:
复制string_ = 'blah' len([string_,]) # returns 1 (其中Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Speech_OneCore\Voices\Tokens\MSTTS_V110_heIL_Asaf是我要在.NET中使用的语音的注册表文件夹,但没有出现在MSTTS_V110_heIL_Asaf中) 到看起来相同的注册表地址,而不是GetInstalledVoices(),而是Speech_OneCore

从技术上讲,要复制注册表文件夹,我导出了原始文件夹,然后编辑.reg文件以将Speech更改为Speech OneCore,然后应用该新的.reg文件。

相关问题