在某些 Android 手机上响应 Native Voice 错误

React Native Voice error on some Android phones

在其中一台设备(Redmi 8A)中,我有输出 Voice.getSpeechRecognitionServices() ==> ["com.xiaomi.mibrain.speech"] 语音识别不工作。 Voice.start() ==> undefined 但是 Voice.isAvailable() ==> true Voice.isRecognizing() ==> true

但是 none 以下事件被触发,

Voice.onSpeechResults
Voice.onSpeechStart
Voice.onSpeechEnd
Voice.onSpeechError
Voice.onSpeechPartialResults

我在安装 Google 应用程序后再次尝试,现在设备 returns ["com.google.android.googlequicksearchbox", "com.xiaomi.mibrain.speech"] 用于 Voice.getSpeechRecognitionServices(),但语音仍然无法正常工作。权限已授予,我可以使用 @react-native-community/audio-toolkit.

进行录制和播放

在logcat:

SpeechRecognizer: bind to recognition service failed
ActivityManager: Unable to start service Intent { act=android.speech.RecognitionService cmp=com.miui.voiceassist/com.xiaomi.mibrain.speech.asr.AsrService } U=0: not found

有没有人遇到过类似的问题并解决了这个问题?有什么建议吗?

设备是运行:

发现即使您有 Google 服务,某些 android 手机也可以配置为使用其他语音识别服务,并且它可能会中断流程,因为 React Native Voice 正在使用 Google 服务。

您可以检查特定 Android Phone 正在使用哪些语音服务,如下所示:

设置 > 应用管理 > 默认应用 > 辅助应用和语音输入 > 辅助应用

希望这对可能面临同样问题的人有所帮助。