前端文字转语音播放
SpeechSynthesisUtterance
纯 web
this.speech = new SpeechSynthesisUtterance();
let speech = this.speech;
speech.text = textMsg.value // 获取并设置说话时的文本
speechSynthesis.speak(speech);
第三方文字转语音播放
百度文字转语音开放 api
const text = '测试文字'
this.testAudio = new Audio()
this.testAudio.src = 'https://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&spd=5&&text=' + text
this.testAudio.muted = false
this.testAudio.play()
最后更新于
这有帮助吗?