React native 0.75 support
SolankiYogesh3500 opened this issue ยท 4 comments
Hi! ๐
Firstly, thanks for your work on this project! ๐
Today I used patch-package to patch @react-native-voice/voice@3.2.4
for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/@react-native-voice/voice/android/build.gradle b/node_modules/@react-native-voice/voice/android/build.gradle
index 8fce879..bda4ee1 100644
--- a/node_modules/@react-native-voice/voice/android/build.gradle
+++ b/node_modules/@react-native-voice/voice/android/build.gradle
@@ -62,6 +62,5 @@ def supportVersion = rootProject.hasProperty('supportLibVersion') ? rootProject.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
- implementation "com.android.support:appcompat-v7:${supportVersion}"
implementation 'com.facebook.react:react-native:+'
}
diff --git a/node_modules/@react-native-voice/voice/android/src/main/java/com/wenkesj/voice/VoiceModule.java b/node_modules/@react-native-voice/voice/android/src/main/java/com/wenkesj/voice/VoiceModule.java
index f22833e..1ab1fea 100644
--- a/node_modules/@react-native-voice/voice/android/src/main/java/com/wenkesj/voice/VoiceModule.java
+++ b/node_modules/@react-native-voice/voice/android/src/main/java/com/wenkesj/voice/VoiceModule.java
@@ -322,10 +322,17 @@ public class VoiceModule extends ReactContextBaseJavaModule implements Recogniti
WritableArray arr = Arguments.createArray();
ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
- for (String result : matches) {
- arr.pushString(result);
+ if (matches != null) {
+ for (String result : matches) {
+ arr.pushString(result);
+ }
+
}
+ if (results == null || results.isEmpty()) {
+ return;
+ }
+
WritableMap event = Arguments.createMap();
event.putArray("value", arr);
sendEvent("onSpeechPartialResults", event);
@@ -345,10 +352,18 @@ public class VoiceModule extends ReactContextBaseJavaModule implements Recogniti
WritableArray arr = Arguments.createArray();
ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
- for (String result : matches) {
- arr.pushString(result);
+ if (matches != null) {
+ for (String result : matches) {
+ arr.pushString(result);
+ }
+
}
+ if (results == null || results.isEmpty()) {
+ return;
+ }
+
+
WritableMap event = Arguments.createMap();
event.putArray("value", arr);
sendEvent("onSpeechResults", event);
diff --git a/node_modules/@react-native-voice/voice/ios/Voice/Voice.m b/node_modules/@react-native-voice/voice/ios/Voice/Voice.m
index fd9dad8..4fae8e3 100644
--- a/node_modules/@react-native-voice/voice/ios/Voice/Voice.m
+++ b/node_modules/@react-native-voice/voice/ios/Voice/Voice.m
@@ -224,6 +224,7 @@ - (void) setupAndStartRecognizing:(NSString*)localeStr {
@try {
[mixer installTapOnBus:0 bufferSize:1024 format:recordingFormat block:^(AVAudioPCMBuffer * _Nonnull buffer, AVAudioTime * _Nonnull when) {
//Volume Level Metering
+ [buffer setFrameLength:buffer.frameCapacity];
UInt32 inNumberFrames = buffer.frameLength;
float LEVEL_LOWPASS_TRIG = 0.5;
if(buffer.format.channelCount>0)
This issue body was partially generated by patch-package.
hey @SolankiYogesh3500 , would this patch make it compatible with the New Architecture (Fabric/Turbo-modules)? I think thats what you meant but just wanted to confirm..
No, it just fixes issues for React Native 0.75 (with the new architecture disabled).
not yet tested with newArch
This package is not compatible with react-native 0.76
its working fine with react-native 0.75
works in 0.76.1 "@react-native-voice/voice": "^3.2.4",
also added above patch as @react-native-voice+voice+3.2.4.patch
This package is not compatible with react-native 0.76 its working fine with react-native 0.75