0

I am trying to change VoiceGender of SpeechSynthesizer object:

SpeechSynthesizer synth = new SpeechSynthesizer();
synth.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Adult);
synth.Speak("Hello! Why is the voice still female?");

The program compiles and runs without errors but the voice is a female voice.

EDIT: I checked installed voices with:

foreach (var v in synth.GetInstalledVoices().Select(v => v.VoiceInfo))
{
    Console.WriteLine("Name:{0}, Gender:{1}, Age:{2}",
    v.Description, v.Gender, v.Age);
}

Which returned the following:

Name:Microsoft Hazel Desktop - English (Great Britain), Gender:Female, Age:Adult
Name:Microsoft David Desktop - English (United States), Gender:Male, Age:Adult
Name:Microsoft Zira Desktop - English (United States), Gender:Female, Age:Adult

EDIT2: Tested it on a different PC and the program works as expected.

Necvetanov
  • 374
  • 3
  • 15
  • [The answer here](https://stackoverflow.com/a/10881620/6741868) might help you, basically you may not have the male voice installed and might need to get it first. `SelectVoiceByHints()` won't throw any exceptions or give any warning if the voice selected is not installed, instead it will keep the default female voice. – Keyur PATEL Jun 27 '17 at 10:07
  • @KeyurPATEL It seems I have 1 male voice installed. – Necvetanov Jun 27 '17 at 10:19
  • The age is `Adult`, so you could try `synth.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Adult);` and perhaps add in a `synth.Volume = 100;` for good measure. – Keyur PATEL Jun 28 '17 at 01:27
  • @KeyurPATEL I tried it and still with the same outcome. – Necvetanov Jun 28 '17 at 13:04
  • Not sure why it is behaving that way, perhaps you could try `synth.SelectVoice("Microsoft David Desktop - English (United States)");` or something like `synth.SelectVoice(synth.GetInstalledVoices().FirstOrDefault(v => v.VoiceInfo.Gender == VoiceGender.Male && v.VoiceInfo.Age == VoiceAge.Adult).Select(v => v.VoiceInfo.Name))`. – Keyur PATEL Jun 29 '17 at 01:31

0 Answers0