react-native-wakeword-sid 1.1.61 → 1.1.62
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.
|
@@ -215,12 +215,101 @@ static Class SVFacadeClass(void) {
|
|
|
215
215
|
return NSClassFromString(@"SpeakerVerificationRNFacade");
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
+
// ============================================================
|
|
219
|
+
// MARK: - Speaker Verification Mic Config JSON resolver (modelPath)
|
|
220
|
+
// ============================================================
|
|
221
|
+
|
|
222
|
+
// Resolve "modelPath" inside mic controller config JSON (bundle name -> absolute file path)
|
|
223
|
+
// so Swift/ORT always receives a real filesystem path.
|
|
224
|
+
static NSString * _Nullable SVResolveMicConfigJson(NSString *configJson, NSError **error) {
|
|
225
|
+
if (!configJson || configJson.length == 0) {
|
|
226
|
+
NSLog(@"[SV][ObjC] SVResolveMicConfigJson: empty configJson");
|
|
227
|
+
return configJson;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
NSData *data = [configJson dataUsingEncoding:NSUTF8StringEncoding];
|
|
231
|
+
if (!data) {
|
|
232
|
+
NSLog(@"[SV][ObjC] SVResolveMicConfigJson: failed to make NSData from JSON string (passing through)");
|
|
233
|
+
return configJson;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
NSError *jsonErr = nil;
|
|
237
|
+
id obj = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonErr];
|
|
238
|
+
if (jsonErr || ![obj isKindOfClass:[NSDictionary class]]) {
|
|
239
|
+
NSLog(@"[SV][ObjC] SVResolveMicConfigJson: JSON parse failed (passing through). err=%@ json=%@", jsonErr, configJson);
|
|
240
|
+
return configJson;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
NSMutableDictionary *cfg = [(NSDictionary *)obj mutableCopy];
|
|
244
|
+
id mp = cfg[@"modelPath"];
|
|
245
|
+
if (![mp isKindOfClass:[NSString class]] || ((NSString *)mp).length == 0) {
|
|
246
|
+
NSLog(@"[SV][ObjC] SVResolveMicConfigJson: missing/invalid modelPath (passing through). keys=%@", cfg.allKeys);
|
|
247
|
+
return configJson;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
NSString *modelPathIn = (NSString *)mp;
|
|
251
|
+
NSLog(@"[SV][ObjC] SVResolveMicConfigJson: modelPath(in)='%@'", modelPathIn);
|
|
252
|
+
|
|
253
|
+
// If already absolute and exists: keep
|
|
254
|
+
if ([modelPathIn hasPrefix:@"/"] && [[NSFileManager defaultManager] fileExistsAtPath:modelPathIn]) {
|
|
255
|
+
NSLog(@"[SV][ObjC] SVResolveMicConfigJson: modelPath absolute & exists ✅");
|
|
256
|
+
return configJson;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Resolve using the SAME logic as createSpeakerVerifier
|
|
260
|
+
NSString *resolved = SVResolveFilePath(modelPathIn);
|
|
261
|
+
if (!resolved) {
|
|
262
|
+
NSArray<NSString *> *onnx = [[NSBundle mainBundle] pathsForResourcesOfType:@"onnx" inDirectory:nil];
|
|
263
|
+
NSLog(@"[SV][ObjC] SVResolveMicConfigJson: ❌ cannot resolve modelPath='%@' in bundle. onnxCount=%lu sample=%@",
|
|
264
|
+
modelPathIn, (unsigned long)onnx.count, onnx.count ? onnx.firstObject : @"(none)");
|
|
265
|
+
if (error) {
|
|
266
|
+
*error = [NSError errorWithDomain:@"SV" code:420 userInfo:@{
|
|
267
|
+
NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Mic config model not found in app bundle: %@", modelPathIn]
|
|
268
|
+
}];
|
|
269
|
+
}
|
|
270
|
+
return nil;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
NSString *stable = SVCopyToTempIfNeeded(resolved, [modelPathIn lastPathComponent]) ?: resolved;
|
|
274
|
+
cfg[@"modelPath"] = stable;
|
|
275
|
+
|
|
276
|
+
NSData *outData = [NSJSONSerialization dataWithJSONObject:cfg options:0 error:&jsonErr];
|
|
277
|
+
if (jsonErr || !outData) {
|
|
278
|
+
NSLog(@"[SV][ObjC] SVResolveMicConfigJson: re-encode failed (passing original). err=%@", jsonErr);
|
|
279
|
+
return configJson;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
NSString *outJson = [[NSString alloc] initWithData:outData encoding:NSUTF8StringEncoding];
|
|
283
|
+
NSLog(@"[SV][ObjC] SVResolveMicConfigJson: modelPath(resolved)='%@'", stable);
|
|
284
|
+
NSLog(@"[SV][ObjC] SVResolveMicConfigJson: json(out)=%@", outJson);
|
|
285
|
+
return outJson;
|
|
286
|
+
}
|
|
287
|
+
|
|
218
288
|
|
|
219
289
|
// =========================
|
|
220
290
|
// MARK: - Mic controller dynamic bridge
|
|
221
291
|
// =========================
|
|
222
292
|
|
|
223
293
|
static id _Nullable SVCreateMicController(NSString *configJson, NSError **error) {
|
|
294
|
+
NSLog(@"[SV][ObjC] SVCreateMicController: in.jsonLen=%lu json=%@",
|
|
295
|
+
(unsigned long)(configJson ? configJson.length : 0),
|
|
296
|
+
configJson ?: @"(null)");
|
|
297
|
+
|
|
298
|
+
// Resolve modelPath inside JSON BEFORE calling Swift
|
|
299
|
+
NSError *resolveErr = nil;
|
|
300
|
+
NSString *fixedJson = SVResolveMicConfigJson(configJson, &resolveErr);
|
|
301
|
+
if (resolveErr || !fixedJson) {
|
|
302
|
+
if (error) *error = resolveErr;
|
|
303
|
+
NSLog(@"[SV][ObjC] SVCreateMicController: ❌ SVResolveMicConfigJson failed: %@", resolveErr.localizedDescription);
|
|
304
|
+
return nil;
|
|
305
|
+
}
|
|
306
|
+
if (![fixedJson isEqualToString:configJson]) {
|
|
307
|
+
NSLog(@"[SV][ObjC] SVCreateMicController: using RESOLVED jsonLen=%lu", (unsigned long)fixedJson.length);
|
|
308
|
+
} else {
|
|
309
|
+
NSLog(@"[SV][ObjC] SVCreateMicController: json unchanged (no modelPath fix needed)");
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
|
|
224
313
|
Class c = SVFacadeClass();
|
|
225
314
|
if (!c) {
|
|
226
315
|
if (error) *error = [NSError errorWithDomain:@"SV" code:10 userInfo:@{NSLocalizedDescriptionKey: @"Swift class SpeakerVerificationRNFacade not found"}];
|
|
@@ -232,7 +321,13 @@ static id _Nullable SVCreateMicController(NSString *configJson, NSError **error)
|
|
|
232
321
|
return nil;
|
|
233
322
|
}
|
|
234
323
|
id (*msgSend)(id, SEL, NSString*, NSError**) = (void*)objc_msgSend;
|
|
235
|
-
|
|
324
|
+
id out = msgSend(c, sel, fixedJson, error);
|
|
325
|
+
if (*error) {
|
|
326
|
+
NSLog(@"[SV][ObjC] SVCreateMicController: ❌ Swift createMicController failed: %@", (*error).localizedDescription);
|
|
327
|
+
} else {
|
|
328
|
+
NSLog(@"[SV][ObjC] SVCreateMicController: ✅ created controller=%@", out);
|
|
329
|
+
}
|
|
330
|
+
return out;
|
|
236
331
|
}
|
|
237
332
|
|
|
238
333
|
static BOOL SVCallBool2(id obj, SEL sel, NSString *s1, NSInteger i1, BOOL b1, NSError **error) {
|
|
@@ -438,6 +533,11 @@ RCT_EXPORT_METHOD(createSpeakerVerificationMicController:(NSString *)controllerI
|
|
|
438
533
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
439
534
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
440
535
|
{
|
|
536
|
+
NSLog(@"[SV][ObjC] createSpeakerVerificationMicController: controllerId=%@ jsonLen=%lu json=%@",
|
|
537
|
+
controllerId,
|
|
538
|
+
(unsigned long)(configJson ? configJson.length : 0),
|
|
539
|
+
configJson ?: @"(null)");
|
|
540
|
+
|
|
441
541
|
if (self.speakerMicControllers[controllerId]) {
|
|
442
542
|
reject(@"SVMicExists", [NSString stringWithFormat:@"Speaker mic controller already exists with ID: %@", controllerId], nil);
|
|
443
543
|
return;
|
|
@@ -448,11 +548,15 @@ RCT_EXPORT_METHOD(createSpeakerVerificationMicController:(NSString *)controllerI
|
|
|
448
548
|
NSError *err = nil;
|
|
449
549
|
id ctrl = SVCreateMicController(configJson, &err);
|
|
450
550
|
if (err || !ctrl) {
|
|
551
|
+
NSLog(@"[SV][ObjC] createSpeakerVerificationMicController: ❌ FAILED err=%@", err.localizedDescription ?: @"(null)");
|
|
552
|
+
|
|
451
553
|
reject(@"SVMicCreateError",
|
|
452
554
|
[NSString stringWithFormat:@"Failed to create mic controller: %@", err.localizedDescription ?: @"unknown"],
|
|
453
555
|
err);
|
|
454
556
|
return;
|
|
455
557
|
}
|
|
558
|
+
NSLog(@"[SV][ObjC] createSpeakerVerificationMicController: ✅ ctrl=%@", ctrl);
|
|
559
|
+
|
|
456
560
|
|
|
457
561
|
// Create delegate proxy that will forward Swift callbacks -> RN events
|
|
458
562
|
SVMicDelegateProxy *proxy = [SVMicDelegateProxy new];
|
|
@@ -461,12 +565,15 @@ RCT_EXPORT_METHOD(createSpeakerVerificationMicController:(NSString *)controllerI
|
|
|
461
565
|
|
|
462
566
|
// Set delegate dynamically (no header needed)
|
|
463
567
|
SVSetDelegate(ctrl, proxy);
|
|
568
|
+
NSLog(@"[SV][ObjC] createSpeakerVerificationMicController: delegate set proxy=%@", proxy);
|
|
464
569
|
|
|
465
570
|
SVMicHolder *h = [SVMicHolder new];
|
|
466
571
|
h.controllerId = controllerId;
|
|
467
572
|
h.controller = ctrl;
|
|
468
573
|
h.delegateProxy = proxy; // keep strong ref
|
|
469
574
|
self.speakerMicControllers[controllerId] = h;
|
|
575
|
+
NSLog(@"[SV][ObjC] createSpeakerVerificationMicController: stored holder. count=%lu",
|
|
576
|
+
(unsigned long)self.speakerMicControllers.count);
|
|
470
577
|
|
|
471
578
|
resolve(@{ @"ok": @YES, @"controllerId": controllerId });
|
|
472
579
|
}
|