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