2017-03-04 118 views
1

我寫代碼CodeGo.net,我用它「System.Speech.Synthesis」庫,但其默認只有英文所以我可以改變它爲法語或其他語言?如何在System.Speech.Synthesis上更改語言?

我的這部分代碼:

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

    } 

我搜索如何改變它在互聯網上,但我不知道很多關於C# 這什麼我found

使我明白任何幫助或建議,從你們並已致謝。

回答

2

您可以選擇預先安裝的語音,以您選擇的語言說話。

我幾乎可以確定,如果您不選擇任何語音,將使用您的計算機/服務器的默認語言。

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

多數民衆贊成它感謝人 – Elmissouri