react-native-wakeword-sid 1.1.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/KeyWordRNBridge.podspec +58 -0
- package/LICENSE +21 -0
- package/README.md +281 -0
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +48 -0
- package/android/libs/com/davoice/keyworddetection/1.0.0/keyworddetection-1.0.0.aar +0 -0
- package/android/libs/com/davoice/keyworddetection/1.0.0/keyworddetection-1.0.0.aar.md5 +1 -0
- package/android/libs/com/davoice/keyworddetection/1.0.0/keyworddetection-1.0.0.aar.sha1 +1 -0
- package/android/libs/com/davoice/keyworddetection/1.0.0/keyworddetection-1.0.0.pom +10 -0
- package/android/libs/com/davoice/keyworddetection/1.0.0/keyworddetection-1.0.0.pom.md5 +1 -0
- package/android/libs/com/davoice/keyworddetection/1.0.0/keyworddetection-1.0.0.pom.sha1 +1 -0
- package/android/settings.gradle +2 -0
- package/android/src/main/AndroidManifest.xml +13 -0
- package/android/src/main/assets/hey_lookdeep.dm +0 -0
- package/android/src/main/assets/layer1.dm +0 -0
- package/android/src/main/assets/need_help_now.dm +0 -0
- package/android/src/main/java/com/davoice/DaVoiceUnifiedPackage.java +29 -0
- package/android/src/main/java/com/davoice/keywordspotting/KeyWordRNBridge.java +335 -0
- package/android/src/main/java/com/davoice/speakeridrn/SpeakerIdRNBridge.java_not_used_yet +588 -0
- package/android/src/main/libs/MyLibrary-release.aar +0 -0
- package/app.plugin.js +60 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/Info.plist +44 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64/KeyWordDetection.framework/Headers/KeyWordDetection-Swift.h +386 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64/KeyWordDetection.framework/Headers/KeyWordDetection.h +18 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64/KeyWordDetection.framework/Info.plist +0 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64/KeyWordDetection.framework/KeyWordDetection +0 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/arm64-apple-ios.abi.json +5758 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/arm64-apple-ios.private.swiftinterface +159 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/arm64-apple-ios.swiftinterface +159 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64/KeyWordDetection.framework/Modules/module.modulemap +11 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Headers/KeyWordDetection-Swift.h +768 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Headers/KeyWordDetection.h +18 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Info.plist +0 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/KeyWordDetection +0 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/arm64-apple-ios-simulator.abi.json +5758 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +159 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/arm64-apple-ios-simulator.swiftinterface +159 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/x86_64-apple-ios-simulator.abi.json +5758 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +159 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +159 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Modules/module.modulemap +11 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/_CodeSignature/CodeDirectory +0 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/_CodeSignature/CodeRequirements +0 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/_CodeSignature/CodeRequirements-1 +0 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/_CodeSignature/CodeResources +297 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/_CodeSignature/CodeSignature +0 -0
- package/ios/KeyWordRNBridge/KeyWordRNBridge.h +19 -0
- package/ios/KeyWordRNBridge/KeyWordRNBridge.m +642 -0
- package/ios/KeyWordRNBridge/KeyWordRNBridge.mm +416 -0
- package/ios/KeyWordRNBridge/models/coca_cola_model_28_05052025.onnx +0 -0
- package/ios/KeyWordRNBridge/models/embedding_model.onnx +0 -0
- package/ios/KeyWordRNBridge/models/hey_lookdeep.onnx +0 -0
- package/ios/KeyWordRNBridge/models/melspectrogram.onnx +0 -0
- package/ios/KeyWordRNBridge/models/need_help_now.onnx +0 -0
- package/ios/KeyWordRNBridge/models/silero_vad.onnx +0 -0
- package/package.json +74 -0
- package/react-native.config.js +10 -0
- package/wakewords/KeyWordRNBridge.d.ts +38 -0
- package/wakewords/KeyWordRNBridge.js +228 -0
- package/wakewords/SpeakerVerificationRNBridge.d.ts +32 -0
- package/wakewords/SpeakerVerificationRNBridge.js +124 -0
- package/wakewords/audioRoutingConfig.d.ts +17 -0
- package/wakewords/audioRoutingConfig.ts +28 -0
- package/wakewords/index.d.ts +16 -0
- package/wakewords/index.js +34 -0
- package/wakewords/useModel.d.ts +19 -0
- package/wakewords/useModel.tsx +235 -0
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
//ios/KeyWordRNBridge.m
|
|
2
|
+
|
|
3
|
+
#import "KeyWordRNBridge.h"
|
|
4
|
+
#import <React/RCTBridge.h>
|
|
5
|
+
#import <React/RCTLog.h>
|
|
6
|
+
#import <React/RCTEventEmitter.h>
|
|
7
|
+
//#import "KeyWordsDetection.h" // Import your KeyWordsDetection library header
|
|
8
|
+
|
|
9
|
+
// Ensure the protocol is correctly imported or declared
|
|
10
|
+
// Assuming the protocol is named 'KeywordDetectionRNDelegate'
|
|
11
|
+
@interface KeyWordsDetectionWrapper : NSObject <KeywordDetectionRNDelegate>
|
|
12
|
+
|
|
13
|
+
@property (nonatomic, strong) KeyWordsDetection *keyWordsDetection;
|
|
14
|
+
@property (nonatomic, strong) NSString *instanceId;
|
|
15
|
+
@property (nonatomic, weak) KeyWordRNBridge *bridge;
|
|
16
|
+
|
|
17
|
+
- (instancetype)initWithInstanceId:(NSString *)instanceId
|
|
18
|
+
modelName:(NSString *)modelName
|
|
19
|
+
threshold:(float)threshold
|
|
20
|
+
bufferCnt:(NSInteger)bufferCnt
|
|
21
|
+
bridge:(KeyWordRNBridge *)bridge
|
|
22
|
+
error:(NSError **)error;
|
|
23
|
+
|
|
24
|
+
- (instancetype)initWithInstanceId:(NSString *)instanceId
|
|
25
|
+
modelNames:(NSArray<NSString *> *)modelNames
|
|
26
|
+
thresholds:(NSArray<NSNumber *> *)thresholds
|
|
27
|
+
bufferCnts:(NSArray<NSNumber *> *)bufferCnts
|
|
28
|
+
msBetweenCallback:(NSArray<NSNumber *> *)msBetweenCallback
|
|
29
|
+
bridge:(KeyWordRNBridge *)bridge
|
|
30
|
+
error:(NSError **)error;
|
|
31
|
+
|
|
32
|
+
@end
|
|
33
|
+
|
|
34
|
+
@implementation KeyWordsDetectionWrapper
|
|
35
|
+
|
|
36
|
+
- (instancetype)initWithInstanceId:(NSString *)instanceId
|
|
37
|
+
modelName:(NSString *)modelName
|
|
38
|
+
threshold:(float)threshold
|
|
39
|
+
bufferCnt:(NSInteger)bufferCnt
|
|
40
|
+
bridge:(KeyWordRNBridge *)bridge
|
|
41
|
+
error:(NSError **)error
|
|
42
|
+
{
|
|
43
|
+
if (self = [super init]) {
|
|
44
|
+
_instanceId = instanceId;
|
|
45
|
+
_bridge = bridge;
|
|
46
|
+
_keyWordsDetection = [[KeyWordsDetection alloc] initWithModelPath:modelName threshold:threshold bufferCnt:bufferCnt error:error];
|
|
47
|
+
if (*error) {
|
|
48
|
+
return nil;
|
|
49
|
+
}
|
|
50
|
+
_keyWordsDetection.delegate = self;
|
|
51
|
+
}
|
|
52
|
+
return self;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
- (instancetype)initWithInstanceId:(NSString *)instanceId
|
|
56
|
+
modelNames:(NSArray<NSString *> *)modelNames
|
|
57
|
+
thresholds:(NSArray<NSNumber *> *)thresholds
|
|
58
|
+
bufferCnts:(NSArray<NSNumber *> *)bufferCnts
|
|
59
|
+
msBetweenCallback:(NSArray<NSNumber *> *)msBetweenCallback
|
|
60
|
+
bridge:(KeyWordRNBridge *)bridge
|
|
61
|
+
error:(NSError **)error {
|
|
62
|
+
if (self = [super init]) {
|
|
63
|
+
_instanceId = instanceId;
|
|
64
|
+
_bridge = bridge;
|
|
65
|
+
|
|
66
|
+
NSMutableArray<NSNumber *> *floatThresholds = [NSMutableArray array];
|
|
67
|
+
for (NSNumber *num in thresholds) {
|
|
68
|
+
[floatThresholds addObject:@(num.floatValue)];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_keyWordsDetection = [[KeyWordsDetection alloc] initWithModelPaths:modelNames
|
|
72
|
+
thresholds:floatThresholds
|
|
73
|
+
bufferCnts:bufferCnts
|
|
74
|
+
msBetweenCallback:msBetweenCallback
|
|
75
|
+
error:error];
|
|
76
|
+
if (*error) return nil;
|
|
77
|
+
_keyWordsDetection.delegate = self;
|
|
78
|
+
}
|
|
79
|
+
return self;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Implement the delegate method
|
|
83
|
+
- (void)KeywordDetectionDidDetectEvent:(NSDictionary *)eventInfo {
|
|
84
|
+
NSMutableDictionary *mutableEventInfo = [eventInfo mutableCopy];
|
|
85
|
+
mutableEventInfo[@"instanceId"] = self.instanceId;
|
|
86
|
+
[_bridge sendEventWithName:@"onKeywordDetectionEvent" body:mutableEventInfo];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@end
|
|
90
|
+
|
|
91
|
+
@interface KeyWordRNBridge () <RCTBridgeModule>
|
|
92
|
+
|
|
93
|
+
@property (nonatomic, strong) NSMutableDictionary *instances;
|
|
94
|
+
|
|
95
|
+
@end
|
|
96
|
+
|
|
97
|
+
@implementation KeyWordRNBridge
|
|
98
|
+
|
|
99
|
+
RCT_EXPORT_MODULE();
|
|
100
|
+
|
|
101
|
+
- (instancetype)init {
|
|
102
|
+
if (self = [super init]) {
|
|
103
|
+
_instances = [NSMutableDictionary new];
|
|
104
|
+
}
|
|
105
|
+
return self;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
+ (BOOL)requiresMainQueueSetup
|
|
109
|
+
{
|
|
110
|
+
return YES;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
114
|
+
return @[@"onKeywordDetectionEvent",
|
|
115
|
+
@"onVADDetectionEvent"]; // NEW
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
RCT_EXPORT_METHOD(createInstanceMulti:(NSString *)instanceId
|
|
119
|
+
modelPaths:(NSArray<NSString *> *)modelPaths
|
|
120
|
+
thresholds:(NSArray<NSNumber *> *)thresholds
|
|
121
|
+
bufferCnts:(NSArray<NSNumber *> *)bufferCnts
|
|
122
|
+
msBetweenCallback:(NSArray<NSNumber *> *)msBetweenCallback
|
|
123
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
124
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
125
|
+
if (self.instances[instanceId]) {
|
|
126
|
+
reject(@"InstanceExists", [NSString stringWithFormat:@"Instance already exists with ID: %@", instanceId], nil);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
NSError *error = nil;
|
|
131
|
+
KeyWordsDetectionWrapper *wrapper = [[KeyWordsDetectionWrapper alloc]
|
|
132
|
+
initWithInstanceId:instanceId
|
|
133
|
+
modelNames:modelPaths
|
|
134
|
+
thresholds:thresholds
|
|
135
|
+
bufferCnts:bufferCnts
|
|
136
|
+
msBetweenCallback:msBetweenCallback
|
|
137
|
+
bridge:self
|
|
138
|
+
error:&error];
|
|
139
|
+
if (error) {
|
|
140
|
+
reject(@"CreateError", [NSString stringWithFormat:@"Failed to create multi-model instance: %@", error.localizedDescription], nil);
|
|
141
|
+
} else {
|
|
142
|
+
self.instances[instanceId] = wrapper;
|
|
143
|
+
resolve([NSString stringWithFormat:@"Multi-model instance created with ID: %@", instanceId]);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
RCT_EXPORT_METHOD(createInstance:(NSString *)instanceId modelName:(NSString *)modelName threshold:(float)threshold bufferCnt:(NSInteger)bufferCnt resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
148
|
+
{
|
|
149
|
+
if (self.instances[instanceId]) {
|
|
150
|
+
reject(@"InstanceExists", [NSString stringWithFormat:@"Instance already exists with ID: %@", instanceId], nil);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
NSError *error = nil;
|
|
155
|
+
KeyWordsDetectionWrapper *wrapper = [[KeyWordsDetectionWrapper alloc] initWithInstanceId:instanceId modelName:modelName threshold:threshold bufferCnt:bufferCnt bridge:self error:&error];
|
|
156
|
+
if (error) {
|
|
157
|
+
reject(@"CreateError", [NSString stringWithFormat:@"Failed to create instance: %@", error.localizedDescription], nil);
|
|
158
|
+
} else {
|
|
159
|
+
self.instances[instanceId] = wrapper;
|
|
160
|
+
resolve([NSString stringWithFormat:@"Instance created with ID: %@", instanceId]);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// NEW: receive global wakeword audio routing config from JS
|
|
165
|
+
RCT_EXPORT_METHOD(setAudioRoutingConfig:(NSString *)jsonConfig
|
|
166
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
167
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
168
|
+
{
|
|
169
|
+
@try {
|
|
170
|
+
// Hand off to your audio/session manager (you implement this)
|
|
171
|
+
// e.g. in AudioSessionAndDuckingManager:
|
|
172
|
+
// - (void)setWakewordAudioRoutingConfigFromJSONString:(NSString *)jsonConfig;
|
|
173
|
+
[AudioSessionAndDuckingManager.shared setWakewordAudioRoutingConfigFromJSONString:jsonConfig];
|
|
174
|
+
|
|
175
|
+
NSLog(@"[KeyWordRNBridge] setAudioRoutingConfig JSON = %@", jsonConfig);
|
|
176
|
+
resolve(@"ok");
|
|
177
|
+
}
|
|
178
|
+
@catch (NSException *e) {
|
|
179
|
+
reject(@"AudioRoutingConfigError",
|
|
180
|
+
[NSString stringWithFormat:@"Failed to set audio routing config: %@", e.reason],
|
|
181
|
+
nil);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
RCT_EXPORT_METHOD(disableDucking:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
186
|
+
{
|
|
187
|
+
[AudioSessionAndDuckingManager.shared disableDucking];
|
|
188
|
+
resolve(@"enabled");
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
RCT_EXPORT_METHOD(initAudioSessAndDuckManage:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
192
|
+
{
|
|
193
|
+
[AudioSessionAndDuckingManager.shared initAudioSessAndDuckManage];
|
|
194
|
+
resolve(@"enabled");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
RCT_EXPORT_METHOD(restartListeningAfterDucking:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
198
|
+
{
|
|
199
|
+
[AudioSessionAndDuckingManager.shared restartListeningAfterDucking];
|
|
200
|
+
resolve(@"disabled");
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
RCT_EXPORT_METHOD(enableAggressiveDucking:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
204
|
+
{
|
|
205
|
+
[AudioSessionAndDuckingManager.shared enableAggressiveDucking];
|
|
206
|
+
resolve(@"enabled");
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
RCT_EXPORT_METHOD(disableDuckingAndCleanup:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
210
|
+
{
|
|
211
|
+
[AudioSessionAndDuckingManager.shared disableDuckingAndCleanup];
|
|
212
|
+
resolve(@"disabled");
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
RCT_EXPORT_METHOD(setKeywordDetectionLicense:(NSString *)instanceId licenseKey:(NSString *)licenseKey resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
216
|
+
{
|
|
217
|
+
KeyWordsDetectionWrapper *wrapper = self.instances[instanceId];
|
|
218
|
+
KeyWordsDetection *instance = wrapper.keyWordsDetection;
|
|
219
|
+
BOOL isLicensed = NO;
|
|
220
|
+
if (instance) {
|
|
221
|
+
isLicensed = [instance setLicenseWithLicenseKey:licenseKey];
|
|
222
|
+
NSLog(@"License is valid?: %@", isLicensed ? @"YES" : @"NO");
|
|
223
|
+
resolve(@(isLicensed)); // Wrap BOOL in NSNumber
|
|
224
|
+
} else {
|
|
225
|
+
reject(@"InstanceNotFound", [NSString stringWithFormat:@"No instance found with ID: %@", instanceId], nil);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
RCT_EXPORT_METHOD(replaceKeywordDetectionModel:(NSString *)instanceId modelName:(NSString *)modelName threshold:(float)threshold bufferCnt:(NSInteger)bufferCnt resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
230
|
+
{
|
|
231
|
+
KeyWordsDetectionWrapper *wrapper = self.instances[instanceId];
|
|
232
|
+
KeyWordsDetection *instance = wrapper.keyWordsDetection;
|
|
233
|
+
if (instance) {
|
|
234
|
+
NSError *error = nil;
|
|
235
|
+
[instance replaceKeywordDetectionModelWithModelPath:modelName threshold:threshold bufferCnt:bufferCnt error:&error];
|
|
236
|
+
if (error) {
|
|
237
|
+
reject(@"ReplaceError", [NSString stringWithFormat:@"Failed to replace model: %@", error.localizedDescription], nil);
|
|
238
|
+
} else {
|
|
239
|
+
resolve([NSString stringWithFormat:@"Instance ID: %@ changed model to %@", instanceId, modelName]);
|
|
240
|
+
}
|
|
241
|
+
} else {
|
|
242
|
+
reject(@"InstanceNotFound", [NSString stringWithFormat:@"No instance found with ID: %@", instanceId], nil);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
RCT_EXPORT_METHOD(startKeywordDetection:(NSString *)instanceId
|
|
247
|
+
threshold:(float)threshold
|
|
248
|
+
noExternalActivation:(BOOL)noExternalActivation
|
|
249
|
+
duckOthers:(BOOL)duckOthers
|
|
250
|
+
mixWithOthers:(BOOL)mixWithOthers
|
|
251
|
+
defaultToSpeaker:(BOOL)defaultToSpeaker
|
|
252
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
253
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
254
|
+
{
|
|
255
|
+
KeyWordsDetectionWrapper *wrapper = self.instances[instanceId];
|
|
256
|
+
KeyWordsDetection *instance = wrapper.keyWordsDetection;
|
|
257
|
+
if (instance) {
|
|
258
|
+
BOOL success = [instance startListeningWithNoExternalActivation:noExternalActivation
|
|
259
|
+
duckOthers:duckOthers
|
|
260
|
+
mixWithOthers:mixWithOthers
|
|
261
|
+
defaultToSpeaker:defaultToSpeaker];
|
|
262
|
+
if (success == false) {
|
|
263
|
+
reject(@"StartError", [NSString stringWithFormat:@"Failed to start detection"], nil);
|
|
264
|
+
} else {
|
|
265
|
+
resolve([NSString stringWithFormat:@"Started detection for instance: %@", instanceId]);
|
|
266
|
+
}
|
|
267
|
+
} else {
|
|
268
|
+
reject(@"InstanceNotFound", [NSString stringWithFormat:@"No instance found with ID: %@", instanceId], nil);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
RCT_EXPORT_METHOD(stopKeywordDetection:(NSString *)instanceId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
273
|
+
{
|
|
274
|
+
KeyWordsDetectionWrapper *wrapper = self.instances[instanceId];
|
|
275
|
+
KeyWordsDetection *instance = wrapper.keyWordsDetection;
|
|
276
|
+
if (instance) {
|
|
277
|
+
[instance stopListening];
|
|
278
|
+
resolve([NSString stringWithFormat:@"Stopped detection for instance: %@", instanceId]);
|
|
279
|
+
} else {
|
|
280
|
+
reject(@"InstanceNotFound", [NSString stringWithFormat:@"No instance found with ID: %@", instanceId], nil);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
RCT_EXPORT_METHOD(destroyInstance:(NSString *)instanceId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
285
|
+
{
|
|
286
|
+
KeyWordsDetectionWrapper *wrapper = self.instances[instanceId];
|
|
287
|
+
if (wrapper) {
|
|
288
|
+
[wrapper.keyWordsDetection stopListening];
|
|
289
|
+
[self.instances removeObjectForKey:instanceId];
|
|
290
|
+
resolve([NSString stringWithFormat:@"Destroyed instance: %@", instanceId]);
|
|
291
|
+
} else {
|
|
292
|
+
reject(@"InstanceNotFound", [NSString stringWithFormat:@"No instance found with ID: %@", instanceId], nil);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Keeping all APIs even if not called in JS yet
|
|
297
|
+
|
|
298
|
+
RCT_EXPORT_METHOD(getKeywordDetectionModel:(NSString *)instanceId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
299
|
+
{
|
|
300
|
+
KeyWordsDetectionWrapper *wrapper = self.instances[instanceId];
|
|
301
|
+
KeyWordsDetection *instance = wrapper.keyWordsDetection;
|
|
302
|
+
if (instance) {
|
|
303
|
+
NSString *modelName = [instance getKeywordDetectionModel];
|
|
304
|
+
resolve(modelName);
|
|
305
|
+
} else {
|
|
306
|
+
reject(@"InstanceNotFound", [NSString stringWithFormat:@"No instance found with ID: %@", instanceId], nil);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
RCT_EXPORT_METHOD(getRecordingWav:(NSString *)instanceId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
311
|
+
{
|
|
312
|
+
KeyWordsDetectionWrapper *wrapper = self.instances[instanceId];
|
|
313
|
+
KeyWordsDetection *instance = wrapper.keyWordsDetection;
|
|
314
|
+
if (instance) {
|
|
315
|
+
NSString *recWavPath = [instance getRecordingWav];
|
|
316
|
+
resolve(recWavPath);
|
|
317
|
+
} else {
|
|
318
|
+
reject(@"InstanceNotFound", [NSString stringWithFormat:@"No instance found with ID: %@", instanceId], nil);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
RCT_EXPORT_METHOD(getVoiceProps:(NSString *)instanceId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
323
|
+
{
|
|
324
|
+
KeyWordsDetectionWrapper *wrapper = self.instances[instanceId];
|
|
325
|
+
KeyWordsDetection *instance = wrapper.keyWordsDetection;
|
|
326
|
+
if (instance) {
|
|
327
|
+
@try {
|
|
328
|
+
NSDictionary *voiceProps = [instance getVoiceProps];
|
|
329
|
+
NSMutableDictionary *result = [NSMutableDictionary dictionary];
|
|
330
|
+
result[@"error"] = voiceProps[@"error"] ?: @"No Error";
|
|
331
|
+
result[@"voiceProbability"] = @([voiceProps[@"voiceProbability"] floatValue]);
|
|
332
|
+
result[@"lastTimeHumanVoiceHeard"] = @([voiceProps[@"lastTimeHumanVoiceHeard"] longLongValue]);
|
|
333
|
+
resolve(result);
|
|
334
|
+
} @catch (NSException *exception) {
|
|
335
|
+
reject(@"VoicePropsError", [NSString stringWithFormat:@"Failed to get voice properties: %@", exception.reason], nil);
|
|
336
|
+
}
|
|
337
|
+
} else {
|
|
338
|
+
reject(@"InstanceNotFound", [NSString stringWithFormat:@"No instance found with ID: %@", instanceId], nil);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Start/stop silent VAD (iOS only)
|
|
343
|
+
RCT_EXPORT_METHOD(startSilentVADDetection:(NSString *)instanceId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
344
|
+
{
|
|
345
|
+
KeyWordsDetectionWrapper *wrapper = self.instances[instanceId];
|
|
346
|
+
if (wrapper && wrapper.keyWordsDetection) {
|
|
347
|
+
BOOL success = [wrapper.keyWordsDetection startSilentListening];
|
|
348
|
+
success ? resolve(@"Started silent VAD detection") :
|
|
349
|
+
reject(@"StartError", @"Failed to start silent VAD detection", nil);
|
|
350
|
+
} else {
|
|
351
|
+
reject(@"InstanceNotFound", @"No instance found", nil);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
RCT_EXPORT_METHOD(stopSilentVADDetection:(NSString *)instanceId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
356
|
+
{
|
|
357
|
+
KeyWordsDetectionWrapper *wrapper = self.instances[instanceId];
|
|
358
|
+
if (wrapper && wrapper.keyWordsDetection) {
|
|
359
|
+
[wrapper.keyWordsDetection stopSilentListening];
|
|
360
|
+
resolve(@"Stopped silent VAD detection");
|
|
361
|
+
} else {
|
|
362
|
+
reject(@"InstanceNotFound", @"No instance found", nil);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// Start/stop explicit VAD
|
|
367
|
+
RCT_EXPORT_METHOD(startVADDetection:(NSString *)instanceId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
368
|
+
{
|
|
369
|
+
KeyWordsDetectionWrapper *wrapper = self.instances[instanceId];
|
|
370
|
+
if (wrapper && wrapper.keyWordsDetection) {
|
|
371
|
+
BOOL success = [wrapper.keyWordsDetection startVADListening];
|
|
372
|
+
success ? resolve(@"Started VAD detection") :
|
|
373
|
+
reject(@"StartError", @"Failed to start VAD detection", nil);
|
|
374
|
+
} else {
|
|
375
|
+
reject(@"InstanceNotFound", @"No instance found", nil);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
RCT_EXPORT_METHOD(stopVADDetection:(NSString *)instanceId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
380
|
+
{
|
|
381
|
+
KeyWordsDetectionWrapper *wrapper = self.instances[instanceId];
|
|
382
|
+
if (wrapper && wrapper.keyWordsDetection) {
|
|
383
|
+
[wrapper.keyWordsDetection stopVADListening];
|
|
384
|
+
resolve(@"Stopped VAD detection");
|
|
385
|
+
} else {
|
|
386
|
+
reject(@"InstanceNotFound", @"No instance found", nil);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
RCT_EXPORT_METHOD(setVADParams:(NSString *)instanceId
|
|
391
|
+
threshold:(float)threshold
|
|
392
|
+
msWindow:(NSInteger)msWindow
|
|
393
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
394
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
395
|
+
{
|
|
396
|
+
KeyWordsDetectionWrapper *wrapper = self.instances[instanceId];
|
|
397
|
+
if (wrapper && wrapper.keyWordsDetection) {
|
|
398
|
+
NSError *err = nil;
|
|
399
|
+
BOOL ok = [wrapper.keyWordsDetection setVADParamsWithThreshold:threshold
|
|
400
|
+
msWindow:msWindow
|
|
401
|
+
error:&err];
|
|
402
|
+
if (!ok || err) {
|
|
403
|
+
reject(@"VADParamsError",
|
|
404
|
+
err ? err.localizedDescription : @"Failed to set VAD params",
|
|
405
|
+
err);
|
|
406
|
+
} else {
|
|
407
|
+
resolve(@"VAD params updated");
|
|
408
|
+
}
|
|
409
|
+
} else {
|
|
410
|
+
reject(@"InstanceNotFound", @"No instance found", nil);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// You can add more methods here as needed, ensuring they use the instanceId
|
|
415
|
+
|
|
416
|
+
@end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-wakeword-sid",
|
|
3
|
+
"version": "1.1.55",
|
|
4
|
+
"description": "Voice/Wake-word detection library for React Native",
|
|
5
|
+
"main": "wakewords/index.js",
|
|
6
|
+
"types": "wakewords/index.d.ts",
|
|
7
|
+
"expo": {
|
|
8
|
+
"plugins": [
|
|
9
|
+
"./app.plugin.js"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"wakewords/",
|
|
14
|
+
"android/",
|
|
15
|
+
"ios/",
|
|
16
|
+
"react-native.config.js",
|
|
17
|
+
"./app.plugin.js",
|
|
18
|
+
"KeyWordRNBridge.podspec"
|
|
19
|
+
],
|
|
20
|
+
"react-native": {
|
|
21
|
+
"ios": "ios",
|
|
22
|
+
"android": "android"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "gradlew assembleRelease"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/react": ">=18.0.0",
|
|
29
|
+
"typescript": ">=4.0.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": ">=18.0.0",
|
|
33
|
+
"react-native": ">=0.70.0"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"react-native wake word",
|
|
37
|
+
"Davoice.io",
|
|
38
|
+
"voice commands",
|
|
39
|
+
"wake word",
|
|
40
|
+
"wakeword",
|
|
41
|
+
"wake words",
|
|
42
|
+
"keyword detection",
|
|
43
|
+
"keyword spotting",
|
|
44
|
+
"Wake word detection github",
|
|
45
|
+
"keyword detection",
|
|
46
|
+
"Phrase Recognition",
|
|
47
|
+
"Phrase Spotting",
|
|
48
|
+
"Voice triggered",
|
|
49
|
+
"hot word",
|
|
50
|
+
"trigger word",
|
|
51
|
+
"speech to intent",
|
|
52
|
+
"voice to intent",
|
|
53
|
+
"phrase spotting",
|
|
54
|
+
"react native wake word",
|
|
55
|
+
"react native Phrase Spotting",
|
|
56
|
+
"react native Voice triggered",
|
|
57
|
+
"react native hot word",
|
|
58
|
+
"Davoice.io wake word",
|
|
59
|
+
"Davoice wake word",
|
|
60
|
+
"Davoice react native wake word",
|
|
61
|
+
"Davoice react-native wake word",
|
|
62
|
+
"wake",
|
|
63
|
+
"word",
|
|
64
|
+
"Voice Commands Recognition",
|
|
65
|
+
"lightweight Voice Commands Recognition",
|
|
66
|
+
"customized lightweight Voice Commands Recognition",
|
|
67
|
+
"Wake word detection github",
|
|
68
|
+
"Wake word generator",
|
|
69
|
+
"Custom wake word",
|
|
70
|
+
"rn wake word"
|
|
71
|
+
],
|
|
72
|
+
"author": "Davoice.io",
|
|
73
|
+
"license": "MIT"
|
|
74
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export class KeyWordRNBridgeInstance {
|
|
2
|
+
constructor(instanceId: any, isSticky: any);
|
|
3
|
+
instanceId: any;
|
|
4
|
+
listeners: any[];
|
|
5
|
+
isFirstInstance: boolean;
|
|
6
|
+
isSticky: any;
|
|
7
|
+
createInstanceMulti(modelNames: any, thresholds: any, bufferCnts: any, msBetweenCallbacks: any): Promise<any>;
|
|
8
|
+
createInstance(modelName: any, threshold: any, bufferCnt: any): Promise<any>;
|
|
9
|
+
getVoiceProps(): Promise<{
|
|
10
|
+
error: any;
|
|
11
|
+
voiceProbability: any;
|
|
12
|
+
lastTimeHumanVoiceHeard: any;
|
|
13
|
+
}>;
|
|
14
|
+
startSilentVADDetection(): Promise<any>;
|
|
15
|
+
stopSilentVADDetection(): Promise<any>;
|
|
16
|
+
startVADDetection(): Promise<any>;
|
|
17
|
+
stopVADDetection(): Promise<any>;
|
|
18
|
+
onVADDetectionEvent(callback: any): import("react-native").EmitterSubscription;
|
|
19
|
+
setVADParams(threshold: any, msWindow: any): Promise<any>;
|
|
20
|
+
getVADParams(): Promise<any>;
|
|
21
|
+
setKeywordDetectionLicense(license: any): Promise<any>;
|
|
22
|
+
replaceKeywordDetectionModel(modelName: any, threshold: any, bufferCnt: any): Promise<any>;
|
|
23
|
+
setKeywordLicense(license: any): Promise<any>;
|
|
24
|
+
startKeywordDetection(threshold: any, setActive?: boolean, duckOthers?: boolean, mixWithOthers?: boolean, defaultToSpeaker?: boolean): Promise<any>;
|
|
25
|
+
getRecordingWav(): Promise<any>;
|
|
26
|
+
stopKeywordDetection(): Promise<any>;
|
|
27
|
+
destroyInstance(): Promise<any>;
|
|
28
|
+
onKeywordDetectionEvent(callback: any): import("react-native").EmitterSubscription;
|
|
29
|
+
removeListeners(): void;
|
|
30
|
+
}
|
|
31
|
+
export function removeAllRNBridgeListeners(): Promise<void>;
|
|
32
|
+
export function createKeyWordRNBridgeInstance(instanceId: any, isSticky: any): Promise<KeyWordRNBridgeInstance>;
|
|
33
|
+
export function enableDucking(): Promise<void>;
|
|
34
|
+
export function disableDucking(): Promise<void>;
|
|
35
|
+
export function restartListeningAfterDucking(): Promise<void>;
|
|
36
|
+
export function initAudioSessAndDuckManage(): Promise<void>;
|
|
37
|
+
export function disableDuckingAndCleanup(): Promise<void>;
|
|
38
|
+
export function setWakewordAudioRoutingConfig(config: any): Promise<any>;
|