概述Web Speech 包含语音识别与语音合成。合成通过 `SpeechSynthesisUtterance` 输出语音,识别在部分浏览器以 `webkitSpeechRecognition` 提供能力。用法/示例const utter = new SpeechSynthesisUtterance('你好,世界') utter.lang = 'zh-CN' speechSynthesis.speak(utter) const Rec = window.SpeechRecognition || window.webkitSpeechRecognition if (Rec) { const rec = new Rec() rec.lang = 'zh-CN' rec.continuous = false rec.interimResults = true rec.onresult = e => { const t = Array.from(e.results).map(r => r[0].transcript).join(' ') } rec.start() } 工程建议明确告知识别的用途与数据处理,遵守隐私与平台政策。对不支持识别的环境提供文本输入回退,并在合成上提供字幕与文字替代。控制合成与识别的语言与速率,保持清晰与稳定。参考与验证MDN:Web Speech API — https://developer.mozilla.org/docs/Web/API/Web_Speech_APIMDN:SpeechSynthesis — https://developer.mozilla.org/docs/Web/API/SpeechSynthesis

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部
1.987781s