SimpleSi
SimpleSi

Reputation: 833

Delay between speech and voice recognition

I'd like to add a delay between the text to speech and the subsequent voice recognition but don't know enough about wait/sleep statements and the concept of not blocking the main thread. Could I have suggestions on how to achieve a wait until the text to speech is finished speaking and the voice recognition starting.

                String myText1 = "Please speak the new speedlimit";
                mTts.speak(myText1, TextToSpeech.QUEUE_FLUSH, null);
                speechSucess = true;
                startVoiceRecognitionActivity();

Upvotes: 0

Views: 1198

Answers (1)

Computerish
Computerish

Reputation: 9591

Set an OnUtteranceCompletedListener and call startVoiceRecognitionActivity(); from the listener's callback function:

http://developer.android.com/reference/android/speech/tts/TextToSpeech.html#setOnUtteranceCompletedListener(android.speech.tts.TextToSpeech.OnUtteranceCompletedListener)

Upvotes: 4

Related Questions