'Why has SpeechRecognizer suddenly stopped working?

My Android app (Xamarin) uses speech recognition. This has worked fine on smartphones with Android 8, 11 and 12. Since a few weeks the speech recognition of my app has stopped working with Android 11 (2 different smartphones tested). It still works fine under Android 8 + 12! The Gboard speech recognition still works on Android 11. There are no updates on my smartphone with Android 11 and also no updates of my app.

OnResults was always called from SpeechRecognizer with the recognized text before. Now, OnResults is called with empty Bundle. OnError is called with SpeechRecognizerError.NoMatch.

If I use an Intent for speech recognition, it works! If I use the SpeechRecognizer with the same parameters, it does not work. I have to use the SpeechRecognizer because I do not want the Android dialog in my app.

So what is different when using SpeechRecognizer?

Logcat:

With Intent only

04-29 12:25:07.004 24526 24672 I A       : TTL (0 seconds) reached - destroy SODA
04-29 12:25:07.007   961   961 D sound_trigger_platform: platform_stdev_check_and_update_concurrency: concurrency active 0, tx 0, rx 0, concurrency session_allowed 1
04-29 12:25:07.009 24526 24667 I A       : Received a final result for a segment
04-29 12:25:07.009 24526 24667 I A       : Received the final result for the recognition
04-29 12:25:07.010 24526 24690 I A       : updated TranscriptionState: TranscriptionState{language=Deutsch (Deutschland), liveTranscription=# com.google.android.apps.search.transcription.f.ay@72c8abf5, finalRecognitionResults=# com.google.android.apps.search.transcription.f.o@c09c735a, hasStartOfSpeech=true, isMicOpen=true, appflowErrorStatus=null, speechLevel=0, audioUri=, lastAudioRationaleToastTimestampLoaded=false} for request-id 1191836547
04-29 12:25:07.010  1477  2981 I system_server: oneway function results will be dropped but finished with status OK and parcel size 4
04-29 12:25:07.010 24526 24526 I A       : #setLatestRecognizedText stableText: Hallo, pendingText: 
04-29 12:25:07.010  1477 27263 I SoundTriggerMiddlewareLogging: setCaptureState[this=com.android.server.soundtrigger_middleware.SoundTriggerMiddlewareImpl@51cdb90, caller=1041/1059](false)
04-29 12:25:07.010 24526 24690 I A       : Offline recognizer - stop detection
04-29 12:25:07.014  1477  2981 I system_server: oneway function results will be dropped but finished with status OK and parcel size 4
04-29 12:25:07.014  1477  2981 I chatty  : uid=1000(system) Binder:1477_14 identical 1 line
04-29 12:25:07.015  1477  2981 I system_server: oneway function results will be dropped but finished with status OK and parcel size 4
04-29 12:25:07.015 24629 24680 I A       : AudioRequestListeningSession stop listening status: CLOSED

With SpeechRecognizer

04-29 12:28:07.216 24526 24690 I A       : TTL (0 seconds) reached - destroy SODA
04-29 12:28:07.224  1477  2951 I system_server: oneway function results will be dropped but finished with status OK and parcel size 4
04-29 12:28:07.246   961 17127 D audio_hw_primary: disable_audio_route: usecase(10) reset and update mixer path: audio-record
04-29 12:28:07.247   961 17127 I soundtrigger: audio_extn_sound_trigger_update_stream_status: send event 12: usecase id 10, type 1
04-29 12:28:07.247   961 17127 D sound_trigger_platform: platform_stdev_check_and_update_concurrency: concurrency active 0, tx 1, rx 0, concurrency session_allowed 1
04-29 12:28:07.247   961 17127 D sound_trigger_platform: platform_stdev_check_concurrency_supported: capture concurrency  allowed, usecase type 1 voice_concur 0 voip_concur 0
04-29 12:28:07.247   961 17127 D audio_hw_primary: disable_snd_device: snd_device(84: voice-rec-mic)
04-29 12:28:07.251   961 17127 D sound_trigger_platform: platform_stdev_check_and_update_concurrency: concurrency active 0, tx 0, rx 0, concurrency session_allowed 1
04-29 12:28:07.254  1477  2951 I system_server: oneway function results will be dropped but finished with status OK and parcel size 4
04-29 12:28:07.254  1477  5904 I SoundTriggerMiddlewareLogging: setCaptureState[this=com.android.server.soundtrigger_middleware.SoundTriggerMiddlewareImpl@51cdb90, caller=1041/1059](false)
04-29 12:28:07.260  1477  5904 I SoundTriggerMiddlewareLogging: setCaptureState[this=com.android.server.soundtrigger_middleware.SoundTriggerMiddlewareImpl@51cdb90, caller=1041/1059](false)
04-29 12:28:07.261  1477  8707 I system_server: oneway function results will be dropped but finished with status OK and parcel size 4
04-29 12:28:07.261 24629 24679 I A       : AudioRequestListeningSession stop listening status: CLOSED

Some details of AndroidManifest.xml:

android:versionCode="30"
android:targetSdkVersion="30" 
android:minSdkVersion="22"

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

<queries>
    <intent>
        <action android:name="android.speech.RecognitionService" />
    </intent>
</queries>

Thanks a lot and have a nice day,



Solution 1:[1]

Try to remove from your intent one or all of the following:

RecognizerIntent.EXTRA_MAX_RESULTS RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS

In my case I had to remove all of 'em otherwise it would not work

Solution 2:[2]

This error is a combination of the Google app update 13.16.8.23.arm64 and some intent parameters usage.

If the following parameters are set

RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS
RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS 
RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS

AND

the latest Google app is installed, the SpeechRecognizer will not work.

If the latest Google app was uninstalled (which will roll back to the older version), the SpeechRecognizer works again, even with this parameters.

If the parameters are removed from code, the SpeechRecognizer works fine, even with the latest Google app.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2