vue 页面文字转播放声音


vue 页面文字转播放声音

1、引入这句话

const synth = window.speechSynthesis;
const msg = new SpeechSynthesisUtterance();

2、引入声音的方法

/** 语音播报的函数/
handleSpeak(e){
msg.text = e;
msg.lang = 'zh-CN';
msg.volume = '1';
msg.rate = 1;
msg.pitch = 1;
synth.speak(msg);
},
/
* 语音停止 */
handleStop(e){
msg.text = e;
msg.lang = 'zh-CN';
synth.cancel(msg);
}

3、需要使用的地方调用

/* 语音播放 */
this.handleSpeak('你好,有新的告警信息产生啦');


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM