我想在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);
}
我应该安装什么东西才能说荷兰语吗?
答案 0 :(得分:0)
实际上,它可以说任何支持所选文化的Windows中安装的语言。你确定你已经安装了一个能说荷兰语的声音(我假设nl-NL
文化)?您应该在OutputVoiceInfo()
方法编写的控制台输出中找到它。
答案 1 :(得分:0)
我有类似的问题。运行以下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 。