c# - SpeechSynthesizer 无法获取所有已安装的声音 3

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

我在区域和语言下使用“添加语言”添加了许多声音。这些出现在 Speech 中的 Text-to-speech 下。 (我使用的是 Windows 10)

我想在我的应用程序中使用这些 SpeechSynthesizer类(class) 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

但是在设置中的 Text-to-speech 下查看还有更多,例如 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 个声音。

我链接的问题中的任何答案都没有帮助我解决我的问题,所以我再次提问。任何帮助表示赞赏。

最佳答案

在尝试了所有已发布的解决方案后,我通过编辑注册表来解决它:
复印Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Speech_OneCore\Voices\Tokens\MSTTS_V110_heIL_Asaf(其中 MSTTS_V110_heIL_Asaf 是我想在 .NET 中使用的语音的注册表文件夹,但不会出现在 GetInstalledVoices() 中)
到一个看起来相同但不是 Speech_OneCore 的注册地址它只是 Speech .
从技术上讲,要复制注册表文件夹,我导出了原始文件夹,然后编辑了 .reg 文件以更改 Speech OneCoreSpeech ,然后应用新的 .reg 文件。

关于c# - SpeechSynthesizer 无法获取所有已安装的声音 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51811901/

相关文章:

.net-core - VS 2017 中缺少 ASP.NET Core 2 模板

c# - 代码先创建表

c# - 确定文本框在其丢失焦点事件中的先前值? WPF

c# - 如果正在使用的 USB COM 端口已被移除,SerialPort.Close() 会卡住应用程序

c# - 所有标准 .net 4.5 库 (dll) 的列表

c# - Azure Functions 绑定(bind)重定向

c# - 在azure虚拟机上部署基于sql server的web服务

c# - ASP.NET Web 应用程序的 SQL 性能不佳

.net - System.Net.Http.HttpClient 是否受到 HttpWebRequest.AllowWriteStreamBuffering 的影响?

visual-studio - Cordova:使用 VS 2017 中的 --allow-file-access-from-files 启动 chrome