我想在C#中更改System.Speech
语音的性别和年龄。例如,一个10岁的女孩,但找不到任何简单的例子来帮助我调整参数。
最佳答案
首先,通过枚举 GetInstalledVoices
类的 SpeechSynthesizer
方法检查已安装的声音,然后使用 SelectVoiceByHints
选择其中之一:
using (SpeechSynthesizer synthesizer = new SpeechSynthesizer())
{
// show installed voices
foreach (var v in synthesizer.GetInstalledVoices().Select(v => v.VoiceInfo))
{
Console.WriteLine("Name:{0}, Gender:{1}, Age:{2}",
v.Description, v.Gender, v.Age);
}
// select male senior (if it exists)
synthesizer.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Senior);
// select audio device
synthesizer.SetOutputToDefaultAudioDevice();
// build and speak a prompt
PromptBuilder builder = new PromptBuilder();
builder.AppendText("Found this on Stack Overflow.");
synthesizer.Speak(builder);
}
关于c# - 如何在C#中更改语音合成器的性别和年龄?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10881370/