using System; using System.Runtime.InteropServices; using System.Speech.Synthesis; using System.Text; namespace HighWayIot.Common { public class SpeechStr { private static readonly Lazy lazy = new Lazy(() => new SpeechStr()); public static SpeechStr Instance { get { return lazy.Value; } } public async void SpeakAsync(string str) { SpeechSynthesizer speech = new SpeechSynthesizer(); speech.Rate = 3;//设置语速 speech.Volume = 100;//设置音量 speech.SelectVoice("Microsoft Huihui Desktop");//设置播音员(中文) speech.SpeakAsync(str); } } }