chrome.tts.speak character limit
Asked Answered
S

1

9

I'm using Chrome's tts service in my extension. According to the chrome.tts documentation:

The maximum length of the text is 32,768 characters.

However, when I pass string that have more than 250 characters the engine will not read all utterance (it will just stop reading it in the middle of the word). I'm now wondering if this is a bug or this is by design. Web speech API have similar character limit described in the spec and it behaves the same way.

I'd like to know if I'm doing something wrong or it only depends on TTS Engine in the browser and I can't do anything with it?

Seaddon answered 8/1, 2015 at 23:41 Comment(2)
You can get reference on this one: #21948230Giddy
Thanks for an answer @gui47, I already saw this post. I was more curios if chrome.tts has different limit than Web Speech API.Seaddon
M
5

I have read official documentations and how you reported it is written that:

The maximum length of the text is 32,768 characters.

Maybe they refer to SSML file max length!

I used chrome api for a while and I can say to you that:

  • The breaking of the utterances only happens when the voice is not a native voice,
  • The cutting out usually occurs between 200-300 characters, When it does break you can un-freeze it by doing speechSynthesis.cancel();
  • The 'onend' event sometimes decides not to fire. A quirky work-around to this is to console.log() out the utterance object before speaking it. Also I found wrapping the speak invocation in a setTimeout callback helps smooth these issues out.

I resolved the problem splitting text:

  • Firstly in sentences (trying non to split them and maintain prosody);
  • If the first step is not sufficient split the sentence again in sub-sentences;

So I suggest to fix the problem this way.

Mere answered 1/7, 2015 at 13:43 Comment(1)
Let me know if you have fixed the problem.Mere

© 2022 - 2024 — McMap. All rights reserved.