2

我正在编写一个使用Web Speech API的SpeechSynthesis Interface的前端用户界面。

我通常对此感到满意。我不关心这些词是否以美国、英国、澳大利亚、猕猴桃、南非、印度、新加坡英语、菲律宾等口音发音,但我不确定当SpeechSynthesis Interface破坏单词时如何处理事情。

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

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

和:

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

例子:

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”,还有其他方法可以用来覆盖破坏?

4

1 回答 1

1

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

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

u.rate = 0.5;
speechSynthesis.speak(u);
于 2021-08-16T16:57:14.603 回答