EddyVerbruggen / nativescript-speech-recognition

:speech_balloon: Speech to text, using the awesome engines readily available on the device.
Other
90 stars 22 forks source link

On Android, "onError" within "startListening" might not produce the desired result #13

Closed gtnunes1956 closed 6 years ago

gtnunes1956 commented 7 years ago

If an error occurs during speech recognition (e.g., to force one, call "startListening" and remain silent), Android will invoke "onError". The current plugin implementation then outputs "Error: 'error-code' " to the console and invokes "reject". Because "resolve" has already been invoked within the Promise (at "onReadyForSpeech"), this has no effect, and the application has no way of knowing about the error.

tushar-1health commented 7 years ago

@EddyVerbruggen Any update on the handler?

EstebanErcole commented 7 years ago

+1

ochemerys commented 6 years ago

"nativescript-speech-recognition": "^1.3.1" still has this issue. Any plans?

neil-119 commented 6 years ago

Same issue still. Any workarounds?

Shne commented 6 years ago

I've made a fork where I've added an onError callback to the options that is called with the error code when an error occurs in android. https://github.com/Shne/nativescript-speech-recognition/commit/bd64fde968959797e23a50dad33bab144e288ef2

I'll open a pull request to see if it can be merged into this and unto npm. Until then, you can use it directly by running tns plugin add https://github.com/Shne/nativescript-speech-recognition/archive/v1.3.2-OnError.tar.gz

You might need to remove the existing plugin first with tns plugin remove nativescript-speech-recognition though I'm not sure that's necessary

EddyVerbruggen commented 6 years ago

Thanks! Give 1.4.0 a spin.

Shne commented 6 years ago

I'm using 1.4.0 now and it's working great.

I did have a problem with it not asking for microphone permission when starting to listen and then failing and logging

Please allow access to the Microphone and try again. (tip: pass in a reject to receive this message in your app)

After I added <uses-permission android:name="android.permission.RECORD_AUDIO" /> in the AndroidManifest.xml it worked fine again. But I'm not entirely sure whether that is caused by a change in the plugin or something else.

EddyVerbruggen commented 6 years ago

@Shne Thanks for reporting back. Hmmm, that permission should be added automatically and I didn't change how that works. Can you check your node_modules/nativescript-speech-recognition/platforms/android folder? it should contain this file which has a permission that should be merged automatically compile-time.

It could be a NativeScript-version issue. What does nativescript --version say?

Shne commented 6 years ago

The file is there, and contains the same. My nativescript version is 4.2.3.

I believe it's just my nativescript and/or sidekick messing up. I've had problems getting it to just deploy correctly.

EddyVerbruggen commented 6 years ago

@Shne Thanks. I'll keep an eye on similar reports for now.

EddyVerbruggen commented 6 years ago

Just released 1.4.1 that may help with sidekick build issues (and should make sure manually adding that permission to your project is no longer needed).

Shne commented 6 years ago

I removed the plugin (with tns plugin remove), removed my added permissions from AndroidManifest.xml, added the plugin again (with tns plugin add) and built and deployed using sidekick, with webpack enabled, and it works and asks for permission!

EddyVerbruggen commented 6 years ago

Awesome 💪