pbakondy / cordova-plugin-speechrecognition

:microphone: Cordova Plugin for Speech Recognition
MIT License
197 stars 117 forks source link

[Suggestion] Speech Recognition seems to not work on Android #102

Open jackie-d opened 4 years ago

jackie-d commented 4 years ago

Hi everybody, just writing a couple line to help everybody to prevent you to use a shotgun against you computer.

I want to underline, that, on iOs everything seems fine, but on Android it seems to exist an issue that make the feature of this plugin to do not work properly.

It comes out when you implement this for both Android and iOs platforms, because, if you've read the doc and still comes to your mind, you'll remember that on Andorid it's not required to call this.speechRecognition.stopListening(); as the platform detects itself when the speech as ended. In counterpart, on iOs, that method it's mandatory to instruct the platform to stop recording and process the input.

The fact, is that, in realty, in Android, the this.speechRecognition.stopListening(); has a bad counter-effect, as it ends up the recording prematurly so it doesn't have the time to process it, and make the effect of the entire plugin to do not work.

To verify if you're affect, you just have to keep your UI button pushed a bit more, let's say, 1s more, after you stop dictate. With this time margin, you'll see the plugin work good.

In my case, I decided to keep the stopListening method even in Android, but to actually retard the action effect of 1 second, as follow:

       setTimeout(() => {
            this.speechRecognition.stopListening();
        }, 1000);

Smooth as the silk.

Cheers, Jackie