C# winform语音提示

1.SpeechSynthesizer文字转音频

项目添加引用:System.Speech

using(SpeechSynthesizer speech = new SpeechSynthesizer)

{

  speech.Rate = 0;  //语速

  speech.Volume = 100;  //音量

  speech.Speak("要播放的文字");

}

 

 

2.SoundPlayer播放本地音频

项目添加引用→COM类型库:Windows Media Player

SoundPlayer play = new SoundPlayer();

play.SoundLocation = AppDomain.CurrentDomain.BaseDirectory + "music.wav"; //本地音频位置,这里放在了当前项目bin→debug下

play.Load();  //加载声音

play.Play(); //播放

 

posted @ 2019-09-03 15:08  你像风  阅读(...)  评论(...编辑  收藏