Change output voice in C#

孤街浪徒 提交于 2019-12-11 03:12:54

问题


Hi I'm just testing SpeechSynthesizer in C# and I want to change the voice.

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");
        }

There is no more Code, just a single button(WinForm). Personally I would say that reader.SelectVoiceByHints(VoiceGender.Male);should be enough. But if I click the button, I still will hear a female voice. What do I need to change? Thank you!


回答1:


I was able to selected specific voices like this:

reader.SelectVoice("Microsoft Zira Desktop");

To get the list of the voices currently installed:

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

}


来源:https://stackoverflow.com/questions/26980895/change-output-voice-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!