v2.1.4
Patch Changes
-
a3aef4e: Add native event error codes for Android.
For advanced use cases where you'd like to debug the platform's underlying speech recognizer you can now access
event.codefrom the error event. For Android, you can import theSpeechRecognizerErrorAndroidenum to match against this code.Error codes with the value of
-1are thrown by this library and not by theSpeechRecognizer.Example use case: differentiating between
ERROR_NETWORKandERROR_NETWORK_TIMEOUTare currently mapped tonetworkonevent.error. With this change you can now useevent.codeto see the exact error that was thrown.import { SpeechRecognizerErrorAndroid, useSpeechRecognitionEvent, } from "expo-speech-recognition"; useSpeechRecognitionEvent("error", (event) => { if (Platform.OS === "android") { switch (event.code) { case SpeechRecognizerErrorAndroid.ERROR_NETWORK: break; case SpeechRecognizerErrorAndroid.ERROR_NETWORK_TIMEOUT: break; case -1: // An error usually thrown by this library break; } } });