使用Web Speech API的SpeechSynthesis接口时如何提高发音

3

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

总体上来说,我很满意。我并不关心单词是以美式、英式、澳大利亚式、新西兰式、南非式、印度式、新加坡式、菲律宾式等口音发音,但当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>

除了创建词对并告诉语音合成器在显示单词“protocols”和“web app”时发音为“proto kols”和“weh bapp”,还有其他方法可以覆盖混淆吗?

1个回答

1

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

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

u.rate = 0.5;
speechSynthesis.speak(u);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接