senzacionale
senzacionale

Reputation: 20916

TextToSpeech how to know when speech is finished with speeking

TextToSpeech tts = new TextToSpeech(context, this);
tts.speak(text, TextToSpeech.QUEUE_ADD, null);

how can i know when speech is finished with speaking, becouse when stop talking i need to execute some extra code. But i have problem becouse i don't knowh how to check if speech is finished with talking.

Is there any option to check this?

Upvotes: 1

Views: 1972

Answers (3)

Sam
Sam

Reputation: 86948

Yes, there are two listeners:


I haven't used the UtteranceProgressListener, but the OnUtteranceCompletedListener is very particular. Here are two tips:

  • Set this listener in the onInit() callback, never before.
  • You must pass the third parameter params to speak() with a valid KEY_PARAM_UTTERANCE_ID, otherwise this listener is never called.

Upvotes: 7

shreks7
shreks7

Reputation: 442

public boolean isDoneSpeaking() {
                   if(!mTts.isSpeaking())
                {
                    return true;
                }
                else
                {
                    return false;
                }

            }

Upvotes: -1

Abhi
Abhi

Reputation: 9005

As for as i know there is no listener for this but we have method called isSpeaking() to check whether TTS engine is busy speaking or not. So that you can take the help of this method to check it is speaking or not

Upvotes: 1

Related Questions