C#播放文字内容

static void Main(string[] args)
{
    try
    {
        SpeechRecognitionEngine recEngine = new SpeechRecognitionEngine();
        SpeechSynthesizer speech = new SpeechSynthesizer();
        speech.Rate = 0;//速度
        speech.Volume = 100;//音量,0-100

        speech.SpeakAsync("欢迎使用电力安全工器具集约化智能管控系统");//异步播放
        Thread.Sleep(2000);
        speech.SpeakAsyncCancelAll();//停止前面的所有播放
        speech.SpeakAsync("中华人民共和国");//异步播放,但是要等到前面的发音完成后才会播放该发音

        speech.Speak("欢迎使用电力安全工器具集约化智能管控系统");
        speech.Speak("中华人民共和国");
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex);
    }

    Console.ReadKey();
}
原文地址:https://www.cnblogs.com/duanjt/p/13094535.html