Search code examples
c#windows-store-appswindows-8.1speech-synthesis

Text to Speech in Window Store App


In my application I am using Text 2 Speech using SpeechSynthesizer.In my code it is speaking with only 3 voices ( One male and two females).My application is for kids so i want voice just like kids how can i achieve that?

CODE:

var synth = new SpeechSynthesizer();

            foreach (var voice in SpeechSynthesizer.AllVoices)
            {
                synth.Voice = voice;

                var text = "Hello World";

                var stream = await synth.SynthesizeTextToStreamAsync(text);

                var me = new MediaElement();
                me.SetSource(stream, stream.ContentType);
                me.Play();

                await Task.Delay(3000);
            }

Solution

  • You can change the Gender and age using StartVoice(VoiceGender gender, VoiceAge age)

    Simple Example:

    PromptBuilder pb = new PromptBuilder();
    
    pb.StartVoice(VoiceGender.Male, VoiceAge.Child);
    pb.AppendText("I like my toy car");
    pb.EndVoice();
    

    You might want to search for TTS's that support your desired picth.

    Here is the link for all languages available: Languages

    Cheers