Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
400 views
in Technique[技术] by (71.8m points)

javascript - SpeechSynthesisUtterance using Google voice has a small text length limit

Does anyone notice the change of SpeechSynthesisUtterance text length limit with a Google voice on Google Chrome (for Windows or Linux as I tested)? In the past, I could create a SpeechSynthesisUtterance with a Google voice and a text length 1000 characters. But today, I find the text length limit is reduced to about 170 characters!!!

I write a test HTML/JS program to show the problem.

<script>
    speechSynthesis.getVoices();
    function play() {
        speechSynthesis.cancel();
        let voices = speechSynthesis.getVoices();
        let ssu = new SpeechSynthesisUtterance(Array.from({ length: 30 }, (v, i) => i).join(', Hello '));
        ssu.voice = voices.find(v => v.voiceURI === 'Google US English');
        speechSynthesis.speak(ssu);
    }
</script>

<button onclick="play()">Play</button>

Please open the following link by Google Chrome for Windows or Linux:

https://jsfiddle.net/mrmyh/4e36s2r1/

Then, press the Play button. You will notice the speaking will stop near "Hello 19," not the expected "Hello 29!"

The small text length limit makes me to use a workaround that splitting a long text to many small chunks. However, speechSynthesis.speak between two text chunks has an obvious sound gap. Too small chunks mean too many sound gaps, and the playing of them results in a poor user experience :(

Another workaround is: not use Google voices but use Microsoft voices on Windows. Unfortunately, Chrome for Linux on Debian 10 KDE supports only Google voices.

Does anyone has a cross-platform solution with no or few sound gaps?

question from:https://stackoverflow.com/questions/65858900/speechsynthesisutterance-using-google-voice-has-a-small-text-length-limit

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...