我的 Android 应用程序 (Xamarin) 使用语音识别。这在 Android 8、11 和 12 的智能手机上运行良好。几周以来,我的应用程序的语音识别已停止在 Android 11 上运行(测试了 2 种不同的智能手机)。
在Android 8 + 12下仍然可以正常运行! Gboard 语音识别在 Android 11 上仍然有效。
我的 Android 11 智能手机没有更新,我的应用程序也没有更新。
OnResults
总是被打来电话SpeechRecognizer
与之前识别的文本。现在,OnResults
用空的 Bundle 来调用。OnError
被称为SpeechRecognizerError.NoMatch
.
如果我使用 Intent 进行语音识别,它就可以工作!如果我使用具有相同参数的 SpeechRecognizer,则它不起作用。我必须使用 SpeechRecognizer,因为我不想在我的应用程序中使用 Android 对话框。
那么使用 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
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>
非常感谢,祝你有愉快的一天,