Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how i can change language on System.Speech.Synthesis?

Tags:

c#

speech

I write Code and i use on it "System.Speech.Synthesis" library but its on default only English So How i can change it to French or other languages ??

This Part of my Code :

class Program
{
    static void Main(string[] args)
    {
       using (SpeechSynthesizer synth = new SpeechSynthesizer()) {  synth.Speak("Welcome To Calcualtor"); }
}

     }

i Search on internet how change it but i dont know much about c# this whats i found

so i appreciate any help or suggestions from you guys and thanks already.

like image 933
Elmissouri Avatar asked Sep 05 '25 03:09

Elmissouri


1 Answers

You can select a pre-installed voice that will speak in you chosen language.

I'm almost sure that the default language of your computer/server will be used if you don't select any voice.

using (SpeechSynthesizer synthesizer = new SpeechSynthesizer())
{
    synthesizer.SetOutputToDefaultAudioDevice();

    // this
    synthesizer.SelectVoice("ScanSoft Virginie_Dri40_16kHz");

    // or this
    synthesizer.SelectVoiceByHints(VoiceGender.Neutral, VoiceAge.NotSet, 0, CultureInfo.GetCultureInfo("fr-fr"));

    synthesizer.Speak("Bonjour !");
}
like image 157
dbraillon Avatar answered Sep 07 '25 22:09

dbraillon