const speech = new SpeechSynthesisUtterance()
// 设置播放内容
speech.text = “播报内容”
// 设置话语的音调(0-2 默认1,值越大越尖锐,越低越低沉)
speech.pitch = 0.8
// 设置说话的速度(0.1-10 默认1,值越大语速越快,越小语速越慢)
speech.rate = 1
// 设置说话的音量
speech.volume = 10
// 设置播放语言
speech.lang = 'zh-CN'
// 播放结束后调用
speech.onend = (event)=>{
}
// 加入播放队列
window.speechSynthesis.speak(speech)
JS文字实时转语音播报
最新推荐文章于 2024-06-15 12:07:56 发布