I just observed an "undocumented anomaly" in Android's TTS engine: If the text to be spoken is too long (greater than 4K characters), then onUtteranceCompleted() for that particular utterance will never arrive...
Has anyone else come across this?
Is this a known bug or limitation?
What could be done to work around this?
I wasn't aware of the limit, as I prefer smaller chunks of speech (useful if pausing or if activity is paused).
When you call speak, you can add the new utterance to the end of the queue using this for queueMode: TextToSpeech.QUEUE_ADD
Test to be sure the sentence doesn't sound different, but I think just automatically parsing at the next sentence (or word if needed) after a cutoff length would work.
I am not sure if this will be helpful in your case, but in a similar situation I used an anonymous broadcast reciever with an IntentFilter for TextToSpeech.ACTION_TTS_QUEUE_PROCESSING_COMPLETED as given below
filter = new IntentFilter(TextToSpeech.ACTION_TTS_QUEUE_PROCESSING_COMPLETED);
receiver = new BroadcastReceiver(){
public void onReceive(Context p1, Intent p2)
{
if (p2.getAction().equals(TextToSpeech.ACTION_TTS_QUEUE_PROCESSING_COMPLETED) && tts != null)
{
//
//code here
}
}
};
context.registerReceiver(receiver, filter);
tts = new TextToSpeech(context, this);
Hope this could be of some help for someone at sometime
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With