voice
voice copied to clipboard
Update VoiceTestFuncComp.tsx
Typescript was complaining with some types.
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()");
}