【问题标题】:Improving pronunciation when using the SpeechSynthesis Interface of the Web Speech API使用 Web Speech API 的 SpeechSynthesis 接口时改进发音
【发布时间】:2021-08-16 16:20:34
【问题描述】:

我正在编写一个前端用户界面,它使用 Web Speech APISpeechSynthesis Interface

我通常对此感到满意。我不关心这些词是否以美国、英国、澳大利亚、新西兰、南非、印度、新加坡英语、菲律宾等口音发音,但我不确定当 SpeechSynthesis 界面 乱字。

到目前为止,我想出的唯一解决方案是替换:

  • 单个字符串(语音合成器说出与用户阅读相同的字符串)

与:

  • 一对字符串(语音合成器说出与用户阅读的字符串不同的字符串 - 指定的对应字符串)

示例:

const buttons = document.querySelectorAll('button');

const speakWord = (e) => {
  
  const word = e.target.dataset.word;
  let utterance = new SpeechSynthesisUtterance(word);
  speechSynthesis.speak(utterance);
}

buttons.forEach((button) => {
  button.addEventListener('click', speakWord, false);
});
h2 {
  display: inline-block;
  margin-right: 12px;
  font-size: 14px;
}

button {
  cursor: pointer;
}
<h2>Say:</h2>
<button type="button" data-word="manifests">"manifests"</button>
<button type="button" data-word="modules">"modules"</button>
<button type="button" data-word="configuration">"configuration"</button>

<br>

<h2>Now say:</h2>
<button type="button" data-word="protocols">"protocols"</button>
<button type="button" data-word="web app">"web app"</button>

<br>

<h2>Finally say:</h2><button type="button" data-word="proto kols">"proto kols"</button>
<button type="button" data-word="weh bapp">"weh bapp"</button>

只需成对创建单词并告诉 语音合成器 说出 “proto kols”“weh bapp” em>"protocols" 和 "web app" 显示给用户,我可以使用其他方法来覆盖 mangling 吗?

【问题讨论】:

    标签: javascript text-to-speech webspeech-api speechsynthesizer


    【解决方案1】:

    我遇到了同样的问题。我尝试将 utterance.rate 参数设置为较低的值。对于英语,当比率设置为 0.5 时,可理解性更好。如果发音速度不是太慢,可以将该参数设置为较低的值。

    const u = new SpeechSynthesisUtterance('web app');
    speechSynthesis.speak(u);
    
    u.rate = 0.5;
    speechSynthesis.speak(u);
    

    【讨论】:

      猜你喜欢
      • 2022-09-27
      • 1970-01-01
      • 2016-10-31
      • 2016-12-08
      • 2015-04-05
      • 2013-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多