voice
voice copied to clipboard
React native 0.75 support
trafficstars
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.