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