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