我在区域和语言下使用“添加语言”添加了许多声音。这些出现在 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 George
和 Microsoft 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 OneCore
至 Speech
,然后应用新的 .reg 文件。
关于c# - SpeechSynthesizer 无法获取所有已安装的声音 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51811901/