react-native-davoice 1.0.5 → 1.0.7

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 (22) hide show
  1. package/TTSRNBridge.podspec +1 -1
  2. package/ios/SpeechBridge/SpeechBridge.m +29 -13
  3. package/ios/TTSRNBridge/DaVoiceTTSBridge.m +13 -15
  4. package/ios/TTSRNBridge/DavoiceTTS.xcframework/Info.plist +5 -5
  5. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/DavoiceTTS +0 -0
  6. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Headers/DavoiceTTS-Swift.h +1 -0
  7. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.abi.json +6281 -6211
  8. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.private.swiftinterface +42 -41
  9. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.swiftinterface +42 -41
  10. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/DavoiceTTS +0 -0
  11. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Headers/DavoiceTTS-Swift.h +2 -0
  12. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.abi.json +6793 -6723
  13. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +44 -43
  14. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.swiftinterface +44 -43
  15. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.abi.json +6793 -6723
  16. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +44 -43
  17. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +44 -43
  18. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeDirectory +0 -0
  19. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeRequirements-1 +0 -0
  20. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeResources +27 -27
  21. package/package.json +1 -1
  22. package/speech/index.ts +9 -4
@@ -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.188" # Update to your package version
5
+ s.version = "1.0.190" # 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 .
@@ -454,21 +454,27 @@ RCT_EXPORT_METHOD(initAll:(NSDictionary *)opts
454
454
  }
455
455
  NSLog(@"[TTS] INIT: modelURL == %@", modelURL);
456
456
 
457
- NSError *err = nil;
458
- self.tts = [[DaVoiceTTS alloc] initWithModel:modelURL error:&err];
459
- if (err || !self.tts) {
460
- self.initializing = NO;
461
- [self.stt destroySpeech:nil];
462
- self.stt = nil;
463
- reject(@"tts_init_failed", err.localizedDescription ?: @"TTS init failed", err);
464
- return;
465
- }
457
+ dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
458
+ NSError *err = nil;
459
+ DaVoiceTTS *tts = [[DaVoiceTTS alloc] initWithModel:modelURL error:&err];
466
460
 
467
- [self wireTTSFinishedCallback];
461
+ dispatch_async(dispatch_get_main_queue(), ^{
462
+ if (err || !tts) {
463
+ self.initializing = NO;
464
+ [self.stt destroySpeech:nil];
465
+ self.stt = nil;
466
+ reject(@"tts_init_failed", err.localizedDescription ?: @"TTS init failed", err);
467
+ return;
468
+ }
468
469
 
469
- self.initialized = YES;
470
- self.initializing = NO;
471
- resolve(@"initialized");
470
+ self.tts = tts;
471
+ [self wireTTSFinishedCallback];
472
+
473
+ self.initialized = YES;
474
+ self.initializing = NO;
475
+ resolve(@"initialized");
476
+ });
477
+ });
472
478
  });
473
479
  }
474
480
 
@@ -491,6 +497,16 @@ RCT_EXPORT_METHOD(unPauseSpeechRecognitionLite:(nonnull NSNumber *)times
491
497
  if (callback) callback(@[@(YES)]);
492
498
  }
493
499
 
500
+ RCT_EXPORT_METHOD(unPauseSpeechRecognitionLiteWithPreFetch:(nonnull NSNumber *)times
501
+ preFetchMs:(nonnull NSNumber *)preFetch
502
+ callback:(RCTResponseSenderBlock)callback)
503
+ {
504
+ // No-op if STT isn't initialized yet (avoid JS error spam).
505
+ if (!self.stt) { if (callback) callback(@[@(YES)]); return; }
506
+ [self.stt unPauseSpeechRecognitionLite:times preFetch:preFetch];
507
+ if (callback) callback(@[@(YES)]);
508
+ }
509
+
494
510
  // Promise-based pause that resolves ONLY when iOS is actually settled in playback (mic released)
495
511
  RCT_EXPORT_METHOD(pauseMicrophoneAsync:(nonnull NSNumber *)timeoutMs
496
512
  resolver:(RCTPromiseResolveBlock)resolve
@@ -101,24 +101,21 @@ RCT_EXPORT_METHOD(initTTS:(NSDictionary *)configDict
101
101
 
102
102
  NSURL *modelURL = [NSURL fileURLWithPath:modelPath];
103
103
 
104
- NSError *error = nil;
105
- // Ensure we touch AVAudio/ORT from main.
106
- dispatch_async(dispatch_get_main_queue(), ^{
107
- NSError *error = nil;
108
- self.ttsInstance = [[DaVoiceTTS alloc] initWithModel:modelURL error:&error];
109
- if (error || !self.ttsInstance) {
110
- reject(@"init_failed", error.localizedDescription ?: @"Failed to initialize", error);
111
- return;
112
- }
104
+ dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
105
+ NSError *error = nil;
106
+ DaVoiceTTS *tts = [[DaVoiceTTS alloc] initWithModel:modelURL error:&error];
107
+ if (error || !tts) {
108
+ reject(@"init_failed", error.localizedDescription ?: @"Failed to initialize", error);
109
+ return;
110
+ }
111
+
112
+ dispatch_async(dispatch_get_main_queue(), ^{
113
+ self.ttsInstance = tts;
113
114
 
114
115
  __weak typeof(self) weakSelf = self;
115
- // Bridge Swift callback -> RN event
116
116
  self.ttsInstance.onLastUtteranceFinished = ^{
117
117
  __strong typeof(weakSelf) strongSelf = weakSelf;
118
- if (!strongSelf) return;
119
- if (!strongSelf.hasListeners) return;
120
-
121
- // Send on main just to be extra safe for JS listeners doing UI work.
118
+ if (!strongSelf || !strongSelf.hasListeners) return;
122
119
  dispatch_async(dispatch_get_main_queue(), ^{
123
120
  [strongSelf sendEventWithName:@"onFinishedSpeaking" body:@{}];
124
121
  });
@@ -126,7 +123,8 @@ RCT_EXPORT_METHOD(initTTS:(NSDictionary *)configDict
126
123
 
127
124
  resolve(@"TTS initialized");
128
125
  });
129
- }
126
+ });
127
+ }
130
128
 
131
129
  RCT_EXPORT_METHOD(speak:(NSString *)text
132
130
  speakerId:(nonnull NSNumber *)speakerId
@@ -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>
@@ -362,6 +362,7 @@ SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, copy) NSArray<NSStri
362
362
  - (BOOL)setLicenseWithLicenseKey:(NSString * _Nonnull)licenseKey SWIFT_WARN_UNUSED_RESULT;
363
363
  - (void)pauseSpeechRecognitionLite;
364
364
  - (void)unPauseSpeechRecognitionLite:(NSNumber * _Nonnull)times;
365
+ - (void)unPauseSpeechRecognitionLite:(NSNumber * _Nonnull)times preFetch:(NSNumber * _Nonnull)preFetch;
365
366
  - (void)pauseMicrophoneAndWait:(NSNumber * _Nonnull)timeoutMs completion:(void (^ _Nonnull)(BOOL, NSString * _Nullable))completion;
366
367
  - (void)unPauseMicrophoneAndWait:(NSNumber * _Nonnull)timeoutMs completion:(void (^ _Nonnull)(BOOL, NSString * _Nullable))completion;
367
368
  - (void)pauseMicrophone;