C# winform语音提示
程序员文章站
2022-08-08 18:14:48
1.SpeechSynthesizer文字转音频 项目添加引用:System.Speech using(SpeechSynthesizer speech = new SpeechSynthesizer) { speech.Rate = 0; //语速 speech.Volume = 100; //音 ......
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(); //播放