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();
}

 

posted @ 2020-06-11 17:18  段江涛IT  阅读(893)  评论(0编辑  收藏  举报
页脚HTML代码