-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Hello, I share this workaround for certain devices, in my case it happened with a Samnsung J1 Mini Prime.
It happened that the user had not selected a voice service and the recognition does not work, nor did he warn of such an error, he only listened and never finished.
Option 1 : RNAndroidSpeechRecognizerModule.java line 83
@ReactMethod
public void isRecognitionAvailable(final Promise promise) {
boolean available = SpeechRecognizer.isRecognitionAvailable(this.reactContext);
Log.d(TAG, "isRecognitionAvailable: " + available);
String s = android.provider.Settings.Secure.getString(reactContext.getContentResolver(), "voice_recognition_service");
if(android.text.TextUtils.isEmpty(s))
available=false;
promise.resolve(available);
}
In this way, notify the user that there is a lack of configuration on your device. But to not be indicating to this that you should install opt for this other solution
Option 2 : RNAndroidSpeechRecognizerModule.java line 110
private void doCreateSpeechRecognizer(final Promise promise) {
String s = android.provider.Settings.Secure.getString(reactContext.getContentResolver(), "voice_recognition_service");
if(android.text.TextUtils.isEmpty(s))
this.speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this.reactContext,ComponentName.unflattenFromString("com.google.android.googlequicksearchbox/com.google.android.voicesearch.serviceapi.GoogleRecognitionService"));
else
this.speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this.reactContext);
this.speechRecognizer.setRecognitionListener(new ListenerMapRecognitionListener(
this.enabledEvents,
this.reactContext.getJSModule(RCTNativeAppEventEmitter.class),
this.eventPrefix
));
promise.resolve(null);
}
I hope this helps someone.
Regards
Metadata
Metadata
Assignees
Labels
No labels