【发布时间】:2020-04-30 23:46:36
【问题描述】:
iOS 13(Safari 和 WkWebView)中似乎存在一个错误,导致 iOS 使用设备语言语音,并且无法通过查看 SpeechSynthesisUtterance 中提供的“语言”来找到合适的语音。
我自己设置了合适的声音来解决这个问题。
其他浏览器/平台不需要此功能(例如 macOS Safari、iOS
this._getUtteranceRate().then((rate) => {
let utterance = new SpeechSynthesisUtterance(words);
utterance.rate = rate;
utterance.lang = 'sv-SE';
utterance.voice = this.voice; //IOS13 fix
window.speechSynthesis.speak(utterance);
});
window.speechSynthesis.onvoiceschanged = () => {
this.setVoice();
}
setVoice() {
this.voice = window.speechSynthesis.getVoices().find((voice) => {
return voice.lang === 'sv-SE';
});
}
【问题讨论】:
标签: ios safari mobile-safari ios13 webspeech-api