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

Update VoiceTestFuncComp.tsx #492

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kaue-Romero
Copy link

Typescript was complaining with some types.

Typescript was complaining with some types.
@pedrol2b
Copy link

pedrol2b commented Apr 4, 2024

The problem is that
both SpeechResultsEvent and SpeechResultsEvent types in VoiceModuleType.ts
define value as a possible undefined

export type SpeechResultsEvent = {
  value?: string[];
};

export type SpeechResultsEvent = {
  value?: string[];
};

even if looks odd setting an value as array or undefined while it could be just and empty array
i think that was intentional because the return of thoose events its an array of the possible recognition
not the words, for example if i said:

Hello world

it would output

[Hello Word, Hello, Hello word, Hallo word]

The weird part is that the method doesnt seen to return an "undefined" or nulish value

  @Override
  public void onResults(Bundle results) {
    WritableArray arr = Arguments.createArray();

    ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    if (matches != null) {
      for (String result : matches) {
        arr.pushString(result);
      }
    }
    WritableMap event = Arguments.createMap();
    event.putArray("value", arr);
    sendEvent("onSpeechResults", event);
    Log.d("ASR", "onResults()");
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants