我如何改变在C#中的语音合成性别和年龄? [英] how I can change the voice synthesizer gender and age in C#?
问题描述
我在编程的新手。我想改变System.Speech的声音的性别和年龄在C#。例如,一个女孩10年却无法找到任何简单的例子来帮我调整参数。
在此先感谢
I am a novice in programming. I would like to change the gender and age of the voice of System.Speech in c#. For example, a girl of 10 years but can not find any simple example to help me adjust the parameters. Thanks in advance
推荐答案
首先,检查哪些音色已通过枚举<一个安装href=\"http://msdn.microsoft.com/en-us/library/system.speech.synthesis.speechsynthesizer.getinstalledvoices.aspx\"><$c$c>GetInstalledVoices$c$c> SpeechSynthesizer
类的方法,然后用 SelectVoiceByHints
来选择其中之一:
First, check which voices you have installed by enumerating the GetInstalledVoices
method of the SpeechSynthesizer
class, and then use SelectVoiceByHints
to select one of them:
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#中的语音合成性别和年龄?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!