react-native-davoice-tts 1.0.324 → 1.0.326

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.
Files changed (23) hide show
  1. package/TTSRNBridge.podspec +1 -1
  2. package/android/libs/com/davoice/tts/1.0.0/tts-1.0.0.aar +0 -0
  3. package/android/libs/com/davoice/tts/1.0.0/tts-1.0.0.aar.md5 +1 -1
  4. package/android/libs/com/davoice/tts/1.0.0/tts-1.0.0.aar.sha1 +1 -1
  5. package/android/src/main/java/com/davoice/stt/rn/STTModule.kt +35 -12
  6. package/ios/SpeechBridge/SpeechBridge.m +96 -1
  7. package/ios/TTSRNBridge/DavoiceTTS.xcframework/Info.plist +5 -5
  8. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/DavoiceTTS +0 -0
  9. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.abi.json +8736 -8687
  10. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.private.swiftinterface +51 -51
  11. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.swiftinterface +51 -51
  12. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/DavoiceTTS +0 -0
  13. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.abi.json +2245 -2196
  14. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +12 -12
  15. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.swiftinterface +12 -12
  16. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.abi.json +2245 -2196
  17. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +12 -12
  18. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +12 -12
  19. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeDirectory +0 -0
  20. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeRequirements-1 +0 -0
  21. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeResources +24 -24
  22. package/package.json +1 -1
  23. package/speech/index.ts +93 -0
@@ -2,7 +2,7 @@ require 'json'
2
2
 
3
3
  Pod::Spec.new do |s|
4
4
  s.name = "TTSRNBridge"
5
- s.version = "1.0.206" # Update to your package version
5
+ s.version = "1.0.208" # Update to your package version
6
6
  s.summary = "TTS for React Native."
7
7
  s.description = <<-DESC
8
8
  A React Native module for tts .
@@ -1 +1 @@
1
- 8dbdfa8152ce930f388bba719cb97f15 tts-1.0.0.aar
1
+ 34d5e94e94ed16ab142e04079aec0966 tts-1.0.0.aar
@@ -1 +1 @@
1
- 650a6e93501b397750b347f3dfee6e2f3a4c8891 tts-1.0.0.aar
1
+ f889edd5126c11cdfebd92848e74fad33ed38345 tts-1.0.0.aar
@@ -35,6 +35,21 @@ class STTModule(private val rc: ReactApplicationContext)
35
35
  return stt!!
36
36
  }
37
37
 
38
+ private fun readOnboardingJson(options: ReadableMap?): String? {
39
+ var onboardingJson: String? = null
40
+ try {
41
+ if (options != null && options.hasKey("onboardingJsonPath") && !options.isNull("onboardingJsonPath")) {
42
+ val p = options.getString("onboardingJsonPath")
43
+ if (!p.isNullOrBlank()) {
44
+ onboardingJson = java.io.File(p).readText(Charsets.UTF_8)
45
+ }
46
+ }
47
+ } catch (_: Throwable) {
48
+ onboardingJson = null
49
+ }
50
+ return onboardingJson
51
+ }
52
+
38
53
  // ===== JS API =====
39
54
 
40
55
  @ReactMethod
@@ -66,22 +81,18 @@ class STTModule(private val rc: ReactApplicationContext)
66
81
  // ANDROID expects (locale, options, callback) like @react-native-voice
67
82
  @ReactMethod
68
83
  fun startSpeech(locale: String?, options: ReadableMap, cb: Callback) {
69
- var onboardingJson: String? = null
70
- try {
71
- if (options.hasKey("onboardingJsonPath") && !options.isNull("onboardingJsonPath")) {
72
- val p = options.getString("onboardingJsonPath")
73
- if (!p.isNullOrBlank()) {
74
- onboardingJson = java.io.File(p).readText(Charsets.UTF_8)
75
- }
76
- }
77
- } catch (_: Throwable) {
78
- onboardingJson = null
79
- }
80
-
84
+ val onboardingJson = readOnboardingJson(options)
81
85
  ensure().startSpeech(locale, onboardingJson, null)
82
86
  cb.invoke(false) // parity with voice: callback(false) on success
83
87
  }
84
88
 
89
+ @ReactMethod
90
+ fun initWithoutModel(locale: String?, options: ReadableMap?, cb: Callback) {
91
+ val onboardingJson = readOnboardingJson(options)
92
+ ensure().startSpeech(locale, onboardingJson, null)
93
+ cb.invoke(false)
94
+ }
95
+
85
96
  @ReactMethod
86
97
  fun stopSpeech(cb: Callback) {
87
98
  stt?.stopSpeech()
@@ -101,6 +112,18 @@ class STTModule(private val rc: ReactApplicationContext)
101
112
  cb.invoke(false)
102
113
  }
103
114
 
115
+ @ReactMethod
116
+ fun destroyWihtouModel(cb: Callback) {
117
+ stt?.destroySpeech()
118
+ stt = null
119
+ cb.invoke(false)
120
+ }
121
+
122
+ @ReactMethod
123
+ fun destroyWithoutModel(cb: Callback) {
124
+ destroyWihtouModel(cb)
125
+ }
126
+
104
127
  @ReactMethod
105
128
  fun isSpeechAvailable(p: Promise) {
106
129
  STT.isSpeechAvailable(rc) { ok -> p.resolve(ok) }
@@ -134,6 +134,8 @@ static AVAudioPCMBuffer *SB_MakeMonoF32Buffer(NSData *raw,
134
134
 
135
135
  // used only to gate TTS init until STT engine is “hot”
136
136
  @property (atomic, assign) BOOL sttEngineHot;
137
+ // retained so we can re-license a fresh STT instance after destroyAll
138
+ @property (nonatomic, copy, nullable) NSString *lastLicenseKey;
137
139
  @end
138
140
 
139
141
  @implementation SpeechBridge
@@ -243,6 +245,9 @@ RCT_EXPORT_MODULE(SpeechBridge)
243
245
  if (!self.stt) {
244
246
  self.stt = [STT new];
245
247
  self.stt.delegate = self;
248
+ if (self.lastLicenseKey) {
249
+ [self.stt setLicenseWithLicenseKey:self.lastLicenseKey];
250
+ }
246
251
  }
247
252
  }
248
253
 
@@ -396,6 +401,7 @@ RCT_EXPORT_METHOD(setLicense:(NSString *)licenseKey
396
401
  }
397
402
 
398
403
  dispatch_async(dispatch_get_main_queue(), ^{
404
+ self.lastLicenseKey = licenseKey;
399
405
  BOOL ttsOk = [DaVoiceTTS activateLicenseWithLicenseKey:licenseKey];
400
406
  [self ensureSTT];
401
407
  BOOL sttOk = [self.stt setLicenseWithLicenseKey:licenseKey];
@@ -444,6 +450,9 @@ RCT_EXPORT_METHOD(initAll:(NSDictionary *)opts
444
450
  if (!self.stt) {
445
451
  self.stt = [STT new];
446
452
  self.stt.delegate = self;
453
+ if (self.lastLicenseKey) {
454
+ [self.stt setLicenseWithLicenseKey:self.lastLicenseKey];
455
+ }
447
456
  }
448
457
  if (onboardingJsonPath && (id)onboardingJsonPath != [NSNull null] && onboardingJsonPath.length > 0) {
449
458
  [self.stt startSpeechWithLocaleStr:locale onboardingJsonPath:onboardingJsonPath];
@@ -501,6 +510,11 @@ RCT_EXPORT_METHOD(initAll:(NSDictionary *)opts
501
510
  }
502
511
  NSLog(@"[TTS] INIT: modelURL == %@", modelURL);
503
512
 
513
+ if (self.tts) {
514
+ @try { [self.tts stopSpeaking]; [self.tts destroy]; } @catch (__unused id e) {}
515
+ self.tts = nil;
516
+ }
517
+
504
518
  dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
505
519
  NSError *err = nil;
506
520
  DaVoiceTTS *tts = [[DaVoiceTTS alloc] initWithModel:modelURL error:&err];
@@ -532,6 +546,55 @@ RCT_EXPORT_METHOD(initAll:(NSDictionary *)opts
532
546
  });
533
547
  }
534
548
 
549
+ RCT_EXPORT_METHOD(initWithoutModel:(NSDictionary *)opts
550
+ resolver:(RCTPromiseResolveBlock)resolve
551
+ rejecter:(RCTPromiseRejectBlock)reject)
552
+ {
553
+ dispatch_async(dispatch_get_main_queue(), ^{
554
+ if (self.initializing) { resolve(@"already_initializing"); return; }
555
+ if (!self.tts) {
556
+ reject(@"no_tts", @"initWithoutModel() requires a successful initAll() first", nil);
557
+ return;
558
+ }
559
+ if (self.initialized && self.stt) {
560
+ resolve(@"already_initialized");
561
+ return;
562
+ }
563
+
564
+ self.initializing = YES;
565
+ self.sttEngineHot = NO;
566
+
567
+ NSString *locale = opts[@"locale"] ?: @"en-US";
568
+ NSString *onboardingJsonPath = opts[@"onboardingJsonPath"];
569
+ NSNumber *timeoutMs = opts[@"timeoutMs"];
570
+
571
+ @try { [self.stt destroySpeech:nil]; } @catch (__unused id e) {}
572
+ self.stt = nil;
573
+
574
+ [self ensureSTT];
575
+ if (onboardingJsonPath && (id)onboardingJsonPath != [NSNull null] && onboardingJsonPath.length > 0) {
576
+ [self.stt startSpeechWithLocaleStr:locale onboardingJsonPath:onboardingJsonPath];
577
+ } else {
578
+ [self.stt startSpeechWithLocaleStr:locale];
579
+ }
580
+
581
+ [self waitForSTTEngineHotWithTimeoutMs:timeoutMs completion:^(BOOL ok) {
582
+ if (!ok) {
583
+ self.initializing = NO;
584
+ self.initialized = NO;
585
+ self.sttEngineHot = NO;
586
+ @try { [self.stt destroySpeech:nil]; } @catch (__unused id e) {}
587
+ self.stt = nil;
588
+ reject(@"stt_init_timeout", @"STT did not become ready before timeout", nil);
589
+ return;
590
+ }
591
+ self.initialized = YES;
592
+ self.initializing = NO;
593
+ resolve(@"initialized_without_model");
594
+ }];
595
+ });
596
+ }
597
+
535
598
  // --- SpeechRecognitionLite pause/unpause (counter-based) ---
536
599
 
537
600
  RCT_EXPORT_METHOD(pauseSpeechRecognitionLite:(RCTResponseSenderBlock)callback)
@@ -685,7 +748,7 @@ RCT_EXPORT_METHOD(destroyAll:(RCTPromiseResolveBlock)resolve
685
748
  rejecter:(RCTPromiseRejectBlock)reject)
686
749
  {
687
750
  dispatch_async(dispatch_get_main_queue(), ^{
688
- if (!self.initialized && !self.initializing) {
751
+ if (!self.tts && !self.stt && !self.initialized && !self.initializing) {
689
752
  resolve(@"already_destroyed");
690
753
  return;
691
754
  }
@@ -706,6 +769,38 @@ RCT_EXPORT_METHOD(destroyAll:(RCTPromiseResolveBlock)resolve
706
769
  });
707
770
  }
708
771
 
772
+ RCT_EXPORT_METHOD(destroyWihtouModel:(RCTPromiseResolveBlock)resolve
773
+ rejecter:(RCTPromiseRejectBlock)reject)
774
+ {
775
+ dispatch_async(dispatch_get_main_queue(), ^{
776
+ if (!self.tts) {
777
+ reject(@"no_tts", @"destroyWihtouModel() requires a successful initAll() first", nil);
778
+ return;
779
+ }
780
+
781
+ if (!self.stt && !self.initialized && !self.initializing) {
782
+ resolve(@"already_destroyed_without_model");
783
+ return;
784
+ }
785
+
786
+ self.initializing = YES;
787
+
788
+ @try { [self.stt destroySpeech:nil]; } @catch (__unused id e) {}
789
+ self.stt = nil;
790
+
791
+ self.sttEngineHot = NO;
792
+ self.initialized = NO;
793
+ self.initializing = NO;
794
+ resolve(@"destroyed_without_model");
795
+ });
796
+ }
797
+
798
+ RCT_EXPORT_METHOD(destroyWithoutModel:(RCTPromiseResolveBlock)resolve
799
+ rejecter:(RCTPromiseRejectBlock)reject)
800
+ {
801
+ [self destroyWihtouModel:resolve rejecter:reject];
802
+ }
803
+
709
804
  #pragma mark - Convenience passthroughs (optional)
710
805
 
711
806
  RCT_EXPORT_METHOD(startSpeech:(NSString *)locale
@@ -8,32 +8,32 @@
8
8
  <key>BinaryPath</key>
9
9
  <string>DavoiceTTS.framework/DavoiceTTS</string>
10
10
  <key>LibraryIdentifier</key>
11
- <string>ios-arm64_x86_64-simulator</string>
11
+ <string>ios-arm64</string>
12
12
  <key>LibraryPath</key>
13
13
  <string>DavoiceTTS.framework</string>
14
14
  <key>SupportedArchitectures</key>
15
15
  <array>
16
16
  <string>arm64</string>
17
- <string>x86_64</string>
18
17
  </array>
19
18
  <key>SupportedPlatform</key>
20
19
  <string>ios</string>
21
- <key>SupportedPlatformVariant</key>
22
- <string>simulator</string>
23
20
  </dict>
24
21
  <dict>
25
22
  <key>BinaryPath</key>
26
23
  <string>DavoiceTTS.framework/DavoiceTTS</string>
27
24
  <key>LibraryIdentifier</key>
28
- <string>ios-arm64</string>
25
+ <string>ios-arm64_x86_64-simulator</string>
29
26
  <key>LibraryPath</key>
30
27
  <string>DavoiceTTS.framework</string>
31
28
  <key>SupportedArchitectures</key>
32
29
  <array>
33
30
  <string>arm64</string>
31
+ <string>x86_64</string>
34
32
  </array>
35
33
  <key>SupportedPlatform</key>
36
34
  <string>ios</string>
35
+ <key>SupportedPlatformVariant</key>
36
+ <string>simulator</string>
37
37
  </dict>
38
38
  </array>
39
39
  <key>CFBundlePackageType</key>