0

我想在 c# 中使用 tts 并且我的代码适用于英语,但现在我想在荷兰语中使用它。

private void btnSpeak_Click(object sender, EventArgs e)
{
     SpeechSynthesizer synthesizer = new SpeechSynthesizer();

     foreach (var v in synthesizer.GetInstalledVoices(CultureInfo.CurrentCulture))
     {
         VoiceInfo info = v.VoiceInfo;
         OutputVoiceInfo(info);
     }

     synthesizer.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Adult, 0, CultureInfo.CurrentCulture);
     synthesizer.Volume = 100;  // 0...100
     synthesizer.Rate = 1;     // -10...10

     // Synchronous
     if(textBox1.Text != null)
         synthesizer.SpeakAsync(textBox1.Text);
}

private static void OutputVoiceInfo(VoiceInfo info)
{
     Console.WriteLine("Name: {0}, culture: {1}, gender: {2}, age: {3}.\n", info.Name, info.Culture, info.Gender, info.Age);
     Console.WriteLine("Description: {0}\n", info.Description);
}

我应该安装什么东西才能说荷兰语吗?

4

2 回答 2

1

我有类似的问题。运行以下 PowerShell 解决了它:

$sourcePath = 'HKLM:\software\Microsoft\Speech_OneCore\Voices\Tokens' #Where the OneCore voices live
$destinationPath = 'HKLM:\SOFTWARE\Microsoft\Speech\Voices\Tokens' #For 64-bit apps
$destinationPath2 = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\SPEECH\Voices\Tokens' #For 32-bit apps
cd $destinationPath
$listVoices = Get-ChildItem $sourcePath
foreach($voice in $listVoices)
{
$source = $voice.PSPath #Get the path of this voices key
copy -Path $source -Destination $destinationPath -Recurse
copy -Path $source -Destination $destinationPath2 -Recurse
}

来源:https ://gist.github.com/hiepxanh/8b6ad80f6d620cd3eaaaa5c1d2c660b2

运行您的示例使用荷兰语 TTS 引擎Microsoft Frank

于 2020-05-28T13:31:37.613 回答
0

实际上它可以说任何安装在 Windows 中支持所选文化的语言。你确定你已经安装了一个能够说荷兰语的声音(我假设是nl-NL文化)?OutputVoiceInfo()您应该在您的方法编写的控制台的输出中找到它。

于 2013-07-15T09:41:57.803 回答