Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Critical mismatch in the API between iOS and Android #43

Closed
Sharcoux opened this issue Nov 14, 2022 · 2 comments
Closed

Critical mismatch in the API between iOS and Android #43

Sharcoux opened this issue Nov 14, 2022 · 2 comments

Comments

@Sharcoux
Copy link

Sharcoux commented Nov 14, 2022

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);
      }
    }
@khromov
Copy link
Contributor

khromov commented Mar 11, 2024

👋 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.

@jcesarmobile
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants