【问题标题】:iOS13 Safari WebSpeechApi Bug: SpeechSynthesisUtterance won't use provided localeiOS13 Safari WebSpeechApi 错误:SpeechSynthesisUtterance 不会使用提供的语言环境
【发布时间】: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


    【解决方案1】:

    似乎需要在 iOS13 的 SpeechSynthesisUtterance 上明确设置语音,因为语言环境不用于查找语音。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-17
      • 2013-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多