Skip to content
This repository was archived by the owner on Jan 31, 2026. It is now read-only.

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()");
  }

@safaiyeh
Copy link
Member

This project has been deprecated and archived. Please migrate to expo-speech-recognition. Thank you for your contribution! ❤️

@safaiyeh safaiyeh closed this Jan 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants