c#语音播报播放语音功能
c#语音播报播放语音功能
public void Speaking(string saying) { string say = saying; Task task = new Task(() => { SpeechSynthesizer speech = new SpeechSynthesizer(); speech.Volume = 100; //音量 CultureInfo keyboardCulture = System.Windows.Forms.InputLanguage.CurrentInputLanguage.Culture; InstalledVoice neededVoice = speech.GetInstalledVoices(keyboardCulture).FirstOrDefault(); if (neededVoice == null) { say = "未知操作"; } else { speech.SelectVoice(neededVoice.VoiceInfo.Name); } speech.Speak(say); }); task.Start(); }
欢迎讨论,相互学习。
cdtxw@foxmail.com