Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chrome.tts.speak character limit

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?

like image 967
Pawel Psztyc Avatar asked Jan 08 '15 23:01

Pawel Psztyc


1 Answers

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.

like image 68
Giuseppe Avatar answered Sep 30 '22 08:09

Giuseppe