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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM