Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onUtteranceCompleted() lost if TTS received is too long

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?

like image 968
an00b Avatar asked Jul 28 '11 17:07

an00b


2 Answers

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.

like image 115
ProjectJourneyman Avatar answered Nov 15 '22 00:11

ProjectJourneyman


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

like image 28
febinkk Avatar answered Nov 15 '22 01:11

febinkk