Css:
<button type="button" onClick={() => speak('你好')}>说话</button>
js:
const speak = (s: any) => {
// 生成需要语音朗读的内容
const utterance = new SpeechSynthesisUtterance(s)
// 由浏览器发起语音朗读的请求
window.speechSynthesis.speak(utterance)
}
谷歌浏览器语音播报方法
于 2023-03-21 14:25:50 首次发布