在C#中更改输出语音

时间:2014-11-17 19:59:05

标签: c# text-to-speech

嗨,我只是在C#中测试SpeechSynthesizer,我想改变声音。

SpeechSynthesizer reader = new SpeechSynthesizer();


private void button1_Click(object sender, EventArgs e)
        {
            reader.Dispose();
            reader = new SpeechSynthesizer();
            reader.SelectVoiceByHints(VoiceGender.Male);
            reader.Speak("Hi how are you baby");
        }

没有更多的代码,只需一个按钮(WinForm)。就个人而言,我会说reader.SelectVoiceByHints(VoiceGender.Male);应该足够了。但如果我点击按钮,我仍会听到女声。我需要改变什么?谢谢!

1 个答案:

答案 0 :(得分:1)

我能够选择这样的特定声音:

reader.SelectVoice("Microsoft Zira Desktop");

获取当前安装的声音列表:

foreach(var voice in reader.GetInstalledVoices()){
    Console.WriteLine(voice.VoiceInfo.Name);

}