voice icon indicating copy to clipboard operation
voice copied to clipboard

why onSpeechRecognized is not called in Android(Very Urgent)

Open smilydronavalli opened this issue 4 years ago • 15 comments

Hi All,

Kindly tell me why onSpeechRecognized() is not working in Android. I did everything like mentioned is document. Voice.isAvailable() is also true

Kindly give me idea why it is not working It is very important for me I am in the mid of project

smilydronavalli avatar May 11 '20 05:05 smilydronavalli

please give me any solutin for this

smilydronavalli avatar May 11 '20 15:05 smilydronavalli

No one gave reply to this issue. I think its major issue

Kindly help me anyone

smilydronavalli avatar May 13 '20 04:05 smilydronavalli

Did you install Google Assistance or other voice recognition engine?

raclee888 avatar May 21 '20 09:05 raclee888

yes

smilydronavalli avatar Jun 04 '20 20:06 smilydronavalli

I am seeing the same, the first call returns a "9 / Insufficient permissions" error, but after that, everything seems to work fine but no results are returned ever.

This is my logcat output with some custom logs inside each event:

2020-06-25 14:34:12.720 2040-2826/? I/ActivityTaskManager: START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.google.android.permissioncontroller cmp=com.google.android.permissioncontroller/com.android.packageinstaller.permission.ui.GrantPermissionsActivity (has extras)} from uid 10264
2020-06-25 14:34:12.733 2040-2826/? I/MediaFocusControl: abandonAudioFocus() from uid/pid 10264/14304 clientId=android.media.AudioManager@64e198aexpo.modules.av.AVManager@f7a62a4

2020-06-25 14:34:12.836 14304-14371/com.thunkable.live.debug I/ReactNativeJS: WE DO HAVE THE PERMISSION
2020-06-25 14:34:12.845 14304-14371/com.thunkable.live.debug I/ReactNativeJS: 'available? ', true
2020-06-25 14:34:12.845 14304-14371/com.thunkable.live.debug I/ReactNativeJS: 'recognising?', true

After a few seconds I see this Exception:

2020-06-25 14:34:17.823 14304-15736/com.thunkable.live.debug W/ConnectionTracker: Exception thrown while unbinding
    java.lang.IllegalArgumentException: Service not registered: ll@ec35e85
        at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1751)
        at android.app.ContextImpl.unbindService(ContextImpl.java:1776)
        at android.content.ContextWrapper.unbindService(ContextWrapper.java:741)
        at ce.b(:com.google.android.gms.dynamite_measurementdynamite@[email protected] (120700-0):1)
        at ce.a(:com.google.android.gms.dynamite_measurementdynamite@[email protected] (120700-0):5)
        at lm.A(:com.google.android.gms.dynamite_measurementdynamite@[email protected] (120700-0):10)
        at kx.a(:com.google.android.gms.dynamite_measurementdynamite@[email protected] (120700-0):3)
        at dx.run(:com.google.android.gms.dynamite_measurementdynamite@[email protected] (120700-0):2)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at iv.run(:com.google.android.gms.dynamite_measurementdynamite@[email protected] (120700-0):15)

This started happening when we moved from expokit to a bare app, so my guess is that there is something wrong in the linking (or lack of linking) step. I have tried the manual linking steps but no luck so far. Will try again.

A short update: I keep seeing the permissions error in the log, even though the app brings up the pop up, the permission is granted, and you can see that the app has microphone access in settings menu:

E/RecognitionService: call for recognition service without RECORD_AUDIO permissions

This happens with a brand new expo bare app, SDK 37. I thought it would be related to the Permissions changes in SDK36, so added the expo-av module to pull in RECORD_AUDIO permissions, but still no luck.

josmas avatar Jun 25 '20 13:06 josmas

Please run following codes and let us know what was the output.

let services = await Voice.getSpeechRecognitionServices();
console.log(services);

Aung-Myint-Thein avatar Aug 21 '20 02:08 Aung-Myint-Thein

I am facing the same problem on IOS it's working perfectly but on my android phone, Huawei mate 10 lite not working I tried asking for AUDIO permission and to use await Voice.start('es_US', { RECOGNIZER_ENGINE: 'GOOGLE', EXTRA_PARTIAL_RESULTS: true, }); also, I used what @Aung-Myint-Thein mention and I put the value of the services instead of GOOGLE in RECOGNIZER_ENGINE: services the output of Voice.getSpeechRecognitionServices(); is com.google.android.googlequicksearchbox still the same network error and onSpeechError: {"error": {"message": "9/Insufficient permissions"}}

on Emulator there is no 9/Insufficient permissions but

[Sun Aug 23 2020 03:36:48.518] LOG onSpeechVolumeChanged: {"value": -2} [Sun Aug 23 2020 03:36:48.590] LOG onSpeechError: {"error": {"message": "2/Network error"}} [Sun Aug 23 2020 03:36:48.789] LOG onSpeechVolumeChanged: {"value": -2.119999885559082} [Sun Aug 23 2020 03:36:48.820] LOG onSpeechStart: {"error": false} [Sun Aug 23 2020 03:36:48.854] LOG onSpeechVolumeChanged: {"value": -2} [Sun Aug 23 2020 03:36:48.931] LOG onSpeechVolumeChanged: {"value": -2} [Sun Aug 23 2020 03:36:48.956] LOG onSpeechError: {"error": {"message": "2/Network error"}} [Sun Aug 23 2020 03:36:55.721] ERROR [TypeError: Network request failed]

please I need Help

HasanAwad avatar Aug 23 '20 00:08 HasanAwad

@Aung-Myint-Thein the output for recognition services is ["com.google.android.googlequicksearchbox"].

I am not seeing the permissions error anymore on emulator, but still get no results back on Android.

josmas avatar Aug 24 '20 12:08 josmas

@josmas I tried on emulator, but this lib not support on emulator. It's only support on real devices.

evtuw avatar Aug 25 '20 09:08 evtuw

I also tested it and it only works on the physical device. Does anyone know any other way to test this on the android emulator?

joaodos3v avatar Aug 30 '20 18:08 joaodos3v

In my case, I went to settings and gave recording permission to the Google app and it worked fine.

Reference: https://stackoverflow.com/questions/46376193/android-speechrecognizer-audio-recording-error/48006238#48006238

ishowta avatar Apr 02 '21 21:04 ishowta

The year is 2024. I have run into this same problem. It seems that it has never been fixed? Has anyone found a solution at all? I see the same problem on both the emulator (API 34) and on a physical phone (Google Pixel 7 Pro). In my case, I am using react-native and the react-native-voice interface over the Android Voice interface.

One strange thing, I see two onAudioStart events in a row, instead of onSpeechStartfollowed by onSpeechRecognized. Some of this may be RNV's say of handling the problem in the native layer. Anyone have any experience with this?

adrian-kaehler avatar Jan 03 '24 17:01 adrian-kaehler

@adrian-kaehler Hello Do you have any updates how to fix it?

YaremaV avatar Jul 23 '24 09:07 YaremaV

@YaremaV sadly, no. This issue seems to have never been resolved and, so far as I know, remains a bug in RNV. There is a (poor) workaround that I found, which is that where onSpeechRecognized is expected, one will often see a second onSpeechStart call. This seems satisfactory under normal operating conditions (i.e. to count the onSpeechStart calls and look for the second one in sequence), but it is not generally robust. There are too many situations in which this simple approach will not give reliable results. I, and others, have posted about it on Android dev boards, but so far, I haven't seen any action on this. I am not sure why it's not a higher priority, it really makes RNV not work reliably.

LBNL, I did some digging into the Android native library that RNV is wrapping around. I don't recall everything I found (this was a while ago...) but it was my recollection that the bug is directly inherited from the native library, not a feature of RNV specifically. Maybe others can chime in on this who have done this digging. Don't take this recollection of mine as gospel. ;P

adrian-kaehler avatar Aug 01 '24 17:08 adrian-kaehler

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

Add the Above code block in the AndroidManifest.xml of @react-native-voice\voice

Path: \node_modules**@react-native-voice\voice**\android\src\main*AndroidManifest.xml*

This works for me.

shreepaulnsg avatar Aug 26 '24 06:08 shreepaulnsg