7

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?

Charles
  • 50,943
  • 13
  • 104
  • 142
an00b
  • 11,338
  • 13
  • 64
  • 101
  • I know this post is a little old, but did you see http://groups.google.com/group/android-developers/browse_thread/thread/16bd7c9b8feb2036# as a potential workaround? It basically says use tts.isSpeaking() as a workaround. – Jack Aug 11 '11 at 19:13

2 Answers2

2

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.

ProjectJourneyman
  • 3,566
  • 1
  • 27
  • 37
  • +1 for being the only one taking up the challenge. Indeed, "faking" long text by breaking it to small chunks is the only workaround I can think of right now. It would have been nice if Google documented this limitation. – an00b Sep 18 '11 at 12:51
1

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

febinkk
  • 84
  • 6