0

I am working on an app with Dialogflow.

The app works fine, except for the listener. I would like the user to read out loud from a wordlist displayed on the screen.

Currently, when the user clicks the button to record, the wordlist shows up (ready to be read) while the listener is not ready. Each word displays for 2 seconds before the next one shows up.

Is there a way for the word to display until the recording is complete before the next word shows up?

kioi
  • 339
  • 2
  • 15
Melanie
  • 13
  • 3

1 Answers1

0

There are a number of approaches to this.

  1. Using a timer You could thread some sort of a count down timer that counts down for the user. This post, discusses this idea more: SpeechRecognizer Time Limit. In that post, the following is proposed:

    Your best bet would be to thread some sort of timer, something like a CountDownTimer:

     yourSpeechListener.startListening(yourRecognizerIntent);
     new CountDownTimer(2000, 1000) {
    
     public void onTick(long millisUntilFinished) {
         //do nothing, just let it tick
     }
    
     public void onFinish() {
         yourSpeechListener.stopListening();
     }   }.start();
    
  2. You can use the EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS RecognizerIntent

Using it to control the amount of silence the recognizer needs to hear before stopping. There are two parameters that can work in a situation like this

EXTRA_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS or EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS

Both serve almost the same purpose, if there is complete_silence for 100ms or possibly for 200ms then the recognizer will stop listening and subsequently process the word that has just been heard. For example:

        Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);          
        intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS, 2000000);   

or

        Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);          
        intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, 2000000);   
kioi
  • 339
  • 2
  • 15
  • Thank you very much! This is for RecognizerIntent and not for Dialogflow, but that helps me for another problem. – Melanie May 21 '18 at 15:33