Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Speech.Synthesis.SpeechSynthesizer - how to customize the voice?

SpeechSynthesizer allows peaking different voices by using SelectVoiceByHints(VoiceGender, VoiceAge)function (as I understood). But no customization happens if I change the gender and voice age.

Can you explain why? And if I'm doing something wrong, what is correct way to do that?

Thank you.

like image 570
Sasha Reminnyi Avatar asked Dec 07 '22 02:12

Sasha Reminnyi


1 Answers

Here's a small test program that you can use to discover installed voices:

using System;
using System.Speech.Synthesis;  // Add reference to System.Speech

class Program {
    static void Main(string[] args) {
        var synth = new SpeechSynthesizer();
        foreach (var voice in synth.GetInstalledVoices()) {
            Console.WriteLine(voice.VoiceInfo.Description);
        }
        Console.ReadLine();
    }
}

Output on my machine: Microsoft Anna - English (United States)

Which is the one and only default voice that's shipped with Windows afaik. Which would of course explain why changing gender and age doesn't have an effect on your machine.

like image 90
Hans Passant Avatar answered Jan 12 '23 03:01

Hans Passant