0

I made an app in Andoid Studio with Java, that will listen to speech, recognize it, turn speech to text, and when I allow it to it will respond back with text to speech.

In the beginning I got a lot of self-repeating, because it listened to itself, spoke back, listenede to itself, spoke back, and so on. So far I have limited this behavior with this code:

Handler handler = new Handler();
handler.postDelayed(new Runnable() {
   public void run() {
       startlytting();
   }
}, 1000);

It still happens somethimes, probably because some response speeches are longer than 1000ms. Is there a way I could know when the text-to-speech is done speaking, and then turn on the speech listener?

Berit Larsen
  • 739
  • 1
  • 12
  • 29
  • 1
    if you are using [`TextToSpeech`](https://developer.android.com/reference/android/speech/tts/TextToSpeech) then you can use [`OnUtteranceCompletedListener`](https://developer.android.com/reference/android/speech/tts/TextToSpeech.OnUtteranceCompletedListener) or [`UtteranceProgressListener`](https://developer.android.com/reference/android/speech/tts/UtteranceProgressListener) – snachmsm Dec 15 '21 at 11:19
  • Thanks, think I got it working :) – Berit Larsen Dec 16 '21 at 17:05

0 Answers0