c# – Windows控制台应用程序语音不会改变

这是我写的代码,从女性合成器声音变为男性,但它不会改变它继续运行女声.知道为什么会这样吗?

//Opening dialog to the user
Console.WriteLine("Console cpu burn by mixedBreed" + "\nPlease wait while I look over your system");
Console.WriteLine();
string author = "Console cpu burn by mixed Breed" + " Please wait while I look over your system";
synth.SelectVoiceByHints(VoiceGender.Male);
synth.Speak(author);

最佳答案 似乎我也无法使SelectVoiceByHints方法起作用,声音永远不会改变.如果你想切换到男声,这里有一些代码可以工作:

using (var synth = new SpeechSynthesizer())
{
    var voices = synth.GetInstalledVoices().Dump();
    var male = voices.FirstOrDefault(v => v.VoiceInfo.Gender == VoiceGender.Male);
    if (male != null)
    {
        synth.SelectVoice(male.VoiceInfo.Name);
    }

    synth.Speak("Hello");
}
点赞