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(); //播放
黄山市民网:https://www.huangshanshimin.com/