简体   繁体   English

chrome 上的语音合成器只播放前 200 个字符

[英]speech synthesizer on chrome only play the first 200 characters

I'm testing the native speech synthesizer in firefox, it works fine, only the pause () function fails, but in chrome, I have more errors, it only plays a short part of the text, only the first 200 characters, and it doesn't play everything else, I tried the library external meSpeak.js and if it plays everything but it takes a long time to load text of 1842 characters with which I did the test, I am using ubuntu system with chrome version 81.0.4044.92 url for testing https://mdn.github.io/web-speech-api/speak-easy-synthesis/ any solution for chrome ??我正在 firefox 中测试原生语音合成器,它工作正常,只有 pause() 函数失败,但在 chrome 中,我有更多错误,它只播放文本的一小部分,只播放前 200 个字符,并且它不播放其他所有内容,我尝试使用外部 meSpeak.js 库,如果它播放所有内容,但加载我进行测试的 1842 个字符的文本需要很长时间,我正在使用 ubuntu 系统和 chrome 版本 81.0.4044.92用于测试的网址 https://mdn.github.io/web-speech-api/speak-easy-synthesis/ chrome 的任何解决方案?? Thanks谢谢

I believe this is an issue with the speech synthesizer chosen.我相信这是所选语音合成器的问题。 If you choose a local voice - one for which the audio can be generated simply by running in-browser / in-OS code on your local computer - then there should be no character limit, unless the voice you chose has such a limit, which doesn't seem likely如果您选择本地语音——只需在本地计算机上运行浏览器内/操作系统内代码即可为其生成音频——那么应该没有字符限制,除非您选择的语音有这样的限制,即似乎不太可能

For example, on Windows, the two local voices I have are Microsoft David Desktop and Microsoft Zira Desktop.例如,在 Windows 上,我拥有的两个本地语音是 Microsoft David Desktop 和 Microsoft Zira Desktop。 If I select these voices, the whole text gets played, regardless of length.如果我选择这些声音,无论长度如何,都会播放整个文本。

In contrast, other voices such as those from Google (eg Google US English) are not local;相比之下,来自谷歌的其他语音(例如谷歌美国英语)不是本地的; they may need to make a network request to parse the text into audio.他们可能需要发出网络请求才能将文本解析为音频。 Google's speech API seems to have a 200 character or so limit on how much text can be translated at once. Google 的语音 API 似乎对一次可以翻译的文本数量有 200 个左右的限制。

If the character limit is a problem, select a voice which is local, rather than one from Google.如果字符限制有问题,请选择本地语音,而不是来自 Google 的语音。

Here's a snippet that'll list your available voices, as well as which are local or not:这是一个片段,将列出您可用的声音,以及哪些是本地的:

 const populateVoiceList = () => { console.log('Logging available voices'); for (const voice of speechSynthesis.getVoices()) { console.log(voice.name, 'local: ' + voice.localService); } }; populateVoiceList(); speechSynthesis.onvoiceschanged = populateVoiceList;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM