简体   繁体   中英

Windows console application voice would not change

Here is the code I am writing to change from the female synth voice to a male but it will not change it continues to run the female voice. Any idea why that might be?

//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);

It seems I can also not get the SelectVoiceByHints method to work, the voice never changes. If you want to switch to a male voice though, here is some code that will work:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM