简体   繁体   中英

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 ?? 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. 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.

If the character limit is a problem, select a voice which is local, rather than one from 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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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