Css:
<button type="button" onClick={() => speak('你好')}>说话</button>
js:
const speak = (s: any) => {
// 生成需要语音朗读的内容
const utterance = new SpeechSynthesisUtterance(s)
// 由浏览器发起语音朗读的请求
window.speechSynthesis.speak(utterance)
}