一行代码纯前端播放文本内容

 

window.speechSynthesis.speak(new window.SpeechSynthesisUtterance('你好,世界!'))

* 可以复制到控制台试听效果

更多资料请见:

https://www.zhangxinxu.com/wordpress/2017/01/html5-speech-recognition-synthesis-api/

https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance/SpeechSynthesisUtterance

 

你可能感兴趣的:(Javascript,开发)