public MicrosoftVoiceReader() { foreach (InstalledVoice iv in Synth.GetInstalledVoices()) { Voicers.Add(iv.VoiceInfo.Name); } //选择不同的发音 //synth.SelectVoice("Microsoft Anna");//美式发音,但只能读英文 //synth.SelectVoice("Microsoft Lili");//能读中英文 //语音识别 //SpeechRecognitionEngine sre = new SpeechRecognitionEngine(); }
public void Speak(string voicer, double volume, double rate, string content) { if (Voicers.Contains(voicer) == false) { return; } Check(ref volume, ref rate); BeginWork(() => { Synth.SelectVoice(voicer); Synth.Volume = (int)volume; Synth.Rate = (int)rate; Synth.Speak(content); }); }
public void Generated(string voicer, double volume, double rate, string content, string file) { if (Voicers.Contains(voicer) == false) { return; } Check(ref volume, ref rate); BeginWork(() => { var path = new System.IO.FileInfo(file); if (path.Directory.Exists == false) { System.IO.Directory.CreateDirectory(path.Directory.FullName); } Synth.SelectVoice(voicer); Synth.Volume = (int)volume; Synth.Rate = (int)rate; Synth.SetOutputToWaveFile(file); Synth.Speak(content); Synth.SetOutputToDefaultAudioDevice(); }); }