Why is SpeechRecognizer busy when I run it after calling onEndOfSpeech?

I am developing in android and use SpeechRecognizer

for continuous speech recognition.

After speech recognition after the following code:

private void startListening(){
    recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en");
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getActivity().getPackageName());
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS,Long.valueOf(3000L));
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,1);
}

      

And call again startListening()

when called onEndOfSpeech

.

But will be called onError

and show SpeechRecognizer.ERROR_RECOGNIZER_BUSY

.

Q1: Why SpeechRecognizer

busy when I start it after a call onEndOfSpeech

?

Q2 How to implement crooect continuous speech recognition method?

+3


source to share


1 answer


The Android Speech Recognition Library is designed in such a way that it will end up using a timeout when heavily used.

As such, there is no official documentation on why Google does this, and even when using Google apps, there is no continuous voice recognition.

To overcome this, we need to play with the callback methods to catch the error and try again. I created a library specifically to overcome this timing problem and I think it will serve your purpose as well.

Go to Github - DroidSpeech and add the library to your project either a clone or you can use the gradle dependency. After adding Droid Speech initialization and setting the listener as below,

DroidSpeech droidSpeech = new DroidSpeech(this, null);
droidSpeech.setOnDroidSpeechListener(this);

      

To start listening to the called user call,



droidSpeech.startDroidSpeechRecognition();

      

And you will get the result of the voice in the listener method,

@Override
public void onDroidSpeechFinalResult(String finalSpeechResult, boolean droidSpeechWillListen)
{
  // Do whatever you want with the speech result
}

      

What makes this library different from

  • Offers support for continuous speech recognition after each word is spoken,
  • You don't need to worry about speech and latency errors as the library will take care of this and make sure it fixes the problem completely.
  • You don't need to write any lines of code specific to speech recognition other than initializing the library and setting listener methods.
  • One can take care to ask the microphone permission for the user if required
  • Takes care of annoying beep if there is a bug
+1


source







All Articles