I am Using
speech = SpeechRecognizer.createSpeechRecognizer(getReactApplicationContext().getApplicationContext());
speech.setRecognitionListener(VoiceAppModule.this);
recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, 100000000);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en");
recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, "com.languageacademy");
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, 10000);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS, 10000);
The Above code for Speech recognition.
@Override public void onResults(Bundle results) {
in about On Result the result is giving Bundle[EMPTY_PARCEL] in Result.
ArrayList matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
I tried in many of the Devices it is mainly giving problem in MI phones having android 11 and also some samsung phones.
Same problem here, this bug started to occur like few days ago.
I think the reason of this bug is the new version of "Google" app (https://play.google.com/store/apps/details?id=com.google.android.googlequicksearchbox), as SpeechRecognizer uses this app to recognize voice.
If you click uinstall "Google" app, it will roll back to older version and onResult callback will work fine.
Solution that fixed my problem was removing:
EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS
extrasNote that it is extremely rare you'd want to specify this value in an intent. Generally, it should be specified only when it is also used as the value for EXTRA_SEGMENTED_SESSION to enable segmented session mode. Note also that certain values may cause undesired or unexpected results - use judiciously!
https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_SEGMENTED_SESSION