• 2024-08-29浏览器读出文本window.speechSynthesis.speak(msg)
      window.speechSynthesis.speak(msg)是用于在浏览器中调用WebSpeechAPI的语音合成功能。这段代码会让浏览器读出msg对象中的文本。//创建一个新的SpeechSynthesisUtterance对象varmsg=newSpeechSynthesisUtterance();//设置要朗读的文本msg.text="Hell
  • 2024-05-21js纯前端实现语音播报,朗读功能
    实现语音播报要有两个原生API分别是【window.speechSynthesis】【SpeechSynthesisUtterance】项目代码//执行函数letvoices,timerVoicestimerVoices=setInterval(()=>{voices=window.speechSynthesis.getVoices()if(voices.length){clearInter