某种语言的 c# GetInstalledVoices

c# GetInstalledVoices in a certain language

我能够获得安装在我的 Windows 10 系统上的所有语音的列表:

var voiceCollection = synthesizer.GetInstalledVoices();

并且我可以从某个区域获取已安装语音的列表,例如:

var voiceCollection = synthesizer.GetInstalledVoices(new CultureInfo("es-ES"));

然而,以上行 不会 return 任何已安装的 es-MEX 声音

我的问题是 - 有没有办法获取所有已安装的特定语言语音的列表 - 例如所有西班牙语[=的语音24=],无论其具体语言环境如何?

在一般情况下,您可以尝试使用 Linq过滤掉 声音:

using System.Linq;

... 

List<InstalledVoice> voices = synthesizer
  .GetInstalledVoices()                                          // all voices
  .Where(voice => voice.VoiceInfo.Culture.Name.StartsWith("es")) // but filtered
  .ToList();                                                     // organized in a list