Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React native 0.75 support #518

Open
SolankiYogesh3500 opened this issue Sep 18, 2024 · 3 comments
Open

React native 0.75 support #518

SolankiYogesh3500 opened this issue Sep 18, 2024 · 3 comments

Comments

@SolankiYogesh3500
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @react-native-voice/[email protected] 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.

@TowhidKashem
Copy link

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..

@SolankiYogesh3500
Copy link
Author

SolankiYogesh3500 commented Oct 14, 2024

No, it just fixes issues for React Native 0.75 (with the new architecture disabled).
not yet tested with newArch

@chqamarali
Copy link

This package is not compatible with react-native 0.76
its working fine with react-native 0.75

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants