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(); //播放