speech-recognition
speech-recognition copied to clipboard
Critical mismatch in the API between iOS and Android
Describe the bug On Android, there is no partial results. The "start()" promise resolves when the user stops speaking, and the voice recognition immediately stops. On iOS, the voice recognition continues until we stop it.
The culprit is the call to resolve
on line 282 of SpeechRecognition.java. I'm not confident enough with the project to try a PR though...
Another issue is the type of the object returned in the onResult. On iOS we receive the results in the matches
property, while it is in the value
property on Android.
The culprit here seems to be the line 389 of SpeechRecognition.java
And finally, when the user stops speaking for a while on Android, the promise is rejected with "no match" error, and the recognition stops. Here, the culprit is probably the internal API, but we solve it by editing the onError method a bit:
public void onError(int error) {
if(SpeechRecognizer.ERROR_NO_MATCH == error) return
SpeechRecognition.this.stopListening();
String errorMssg = getErrorText(error);
if (this.call != null) {
call.reject(errorMssg);
}
}
👋 Can confirm that this is still an issue as of March 2024. It would be good to at least document the differences and which strategies can be employed (due to lack of isListening() API) to handle automatic stopping of recognition on iOS.
closing since android has partial results now, and doesn't return value
but matches
as on iOS, so seems out of date.
Also, there is a isListening method and a listeningState listener.
If there are still differences, please, create a new issue and provide a sample app that reproduces the problem.