react-native-davoice-tts 1.0.395 → 1.0.396

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 (27) 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/ios/TTSRNBridge/DaVoiceTTSBridge.m +75 -24
  6. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/DavoiceTTS +0 -0
  7. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Headers/DavoiceTTS-Swift.h +23 -0
  8. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.abi.json +916 -320
  9. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.private.swiftinterface +15 -0
  10. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  11. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.swiftinterface +15 -0
  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/Headers/DavoiceTTS-Swift.h +46 -0
  14. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.abi.json +916 -320
  15. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +15 -0
  16. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  17. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.swiftinterface +15 -0
  18. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.abi.json +916 -320
  19. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +15 -0
  20. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  21. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +15 -0
  22. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeDirectory +0 -0
  23. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeRequirements-1 +0 -0
  24. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeResources +33 -33
  25. package/package.json +1 -1
  26. package/speech/index.d.ts +263 -0
  27. package/speech/index.ts +50 -29
@@ -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.375" # Update to your package version
5
+ s.version = "1.0.377" # 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
- ce637f9ae253c71eab5dbfbabe6335a7 tts-1.0.0.aar
1
+ b2bbfb5fb59b4529ddc6a6e9ebb9a69a tts-1.0.0.aar
@@ -1 +1 @@
1
- 2404e2f50ac6d464affe24a6db99486113f92ff1 tts-1.0.0.aar
1
+ 827b55bde2ad6f58b9dcbb9d538917ab978d660c tts-1.0.0.aar
@@ -149,6 +149,54 @@ RCT_EXPORT_MODULE();
149
149
  return [NSURL fileURLWithPath:pathOrURL];
150
150
  }
151
151
 
152
+ // Model initialization must not perform remote I/O on the React Native bridge
153
+ // queue. Local paths are resolved asynchronously as well, so initTTS has one
154
+ // consistent completion path and never blocks the bridge while resolving a model.
155
+ - (void)resolveModelURLFromPathOrURL:(NSString *)pathOrURL
156
+ completion:(void (^)(NSURL * _Nullable modelURL))completion
157
+ {
158
+ if (!pathOrURL || (id)pathOrURL == [NSNull null] || pathOrURL.length == 0) {
159
+ dispatch_async(dispatch_get_main_queue(), ^{ completion(nil); });
160
+ return;
161
+ }
162
+
163
+ NSURL *candidate = [NSURL URLWithString:pathOrURL];
164
+ BOOL isRemote = [pathOrURL hasPrefix:@"http://"] || [pathOrURL hasPrefix:@"https://"];
165
+ if (!isRemote) {
166
+ dispatch_async(dispatch_get_global_queue(QOS_CLASS_UTILITY, 0), ^{
167
+ NSURL *url = [self resolveLocalURLFromPathOrURL:pathOrURL];
168
+ dispatch_async(dispatch_get_main_queue(), ^{ completion(url); });
169
+ });
170
+ return;
171
+ }
172
+
173
+ if (!candidate) {
174
+ dispatch_async(dispatch_get_main_queue(), ^{ completion(nil); });
175
+ return;
176
+ }
177
+
178
+ NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration];
179
+ configuration.timeoutIntervalForRequest = 8.0;
180
+ configuration.timeoutIntervalForResource = 15.0;
181
+ NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
182
+ NSURLSessionDataTask *task = [session dataTaskWithURL:candidate
183
+ completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
184
+ NSInteger status = [response isKindOfClass:[NSHTTPURLResponse class]]
185
+ ? ((NSHTTPURLResponse *)response).statusCode : 200;
186
+ NSURL *result = nil;
187
+ if (!error && data.length > 0 && status < 400) {
188
+ NSString *extension = candidate.pathExtension.length ? candidate.pathExtension : @"bin";
189
+ NSString *name = [NSString stringWithFormat:@"rn_model_%f.%@",
190
+ [[NSDate date] timeIntervalSince1970], extension];
191
+ NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:name];
192
+ if ([data writeToFile:path atomically:YES]) result = [NSURL fileURLWithPath:path];
193
+ }
194
+ [session finishTasksAndInvalidate];
195
+ dispatch_async(dispatch_get_main_queue(), ^{ completion(result); });
196
+ }];
197
+ [task resume];
198
+ }
199
+
152
200
  RCT_EXPORT_METHOD(setLicense:(NSString *)licenseKey
153
201
  resolver:(RCTPromiseResolveBlock)resolve
154
202
  rejecter:(RCTPromiseRejectBlock)reject)
@@ -191,36 +239,39 @@ RCT_EXPORT_METHOD(initTTS:(NSDictionary *)configDict
191
239
  return;
192
240
  }
193
241
 
194
- NSURL *modelURL = [self resolveLocalURLFromPathOrURL:modelPath];
195
- if (!modelURL) {
196
- reject(@"bad_model", [NSString stringWithFormat:@"Could not resolve model path: %@", modelPath], nil);
197
- return;
198
- }
199
-
200
- dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
201
- NSError *error = nil;
202
- DaVoiceTTS *tts = [[DaVoiceTTS alloc] initWithModel:modelURL error:&error];
203
- if (error || !tts) {
204
- reject(@"init_failed", error.localizedDescription ?: @"Failed to initialize", error);
242
+ [self resolveModelURLFromPathOrURL:modelPath completion:^(NSURL *modelURL) {
243
+ if (!modelURL) {
244
+ reject(@"bad_model", [NSString stringWithFormat:@"Could not resolve model path: %@", modelPath], nil);
205
245
  return;
206
246
  }
207
247
 
208
- dispatch_async(dispatch_get_main_queue(), ^{
209
- if (self.ttsInstance) {
210
- @try { [self.ttsInstance stopSpeaking]; [self.ttsInstance destroy]; } @catch (__unused id e) {}
211
- }
212
- self.ttsInstance = tts;
213
-
214
- __weak typeof(self) weakSelf = self;
215
- self.ttsInstance.onLastUtteranceFinished = ^{
216
- __strong typeof(weakSelf) strongSelf = weakSelf;
217
- if (!strongSelf || !strongSelf.hasListeners) return;
248
+ dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
249
+ NSError *error = nil;
250
+ DaVoiceTTS *tts = [[DaVoiceTTS alloc] initWithModel:modelURL error:&error];
251
+ if (error || !tts) {
218
252
  dispatch_async(dispatch_get_main_queue(), ^{
219
- [strongSelf sendEventWithName:@"onFinishedSpeaking" body:@{}];
253
+ reject(@"init_failed", error.localizedDescription ?: @"Failed to initialize", error);
220
254
  });
221
- };
255
+ return;
256
+ }
222
257
 
223
- resolve(@"TTS initialized");
258
+ dispatch_async(dispatch_get_main_queue(), ^{
259
+ if (self.ttsInstance) {
260
+ @try { [self.ttsInstance stopSpeaking]; [self.ttsInstance destroy]; } @catch (__unused id e) {}
261
+ }
262
+ self.ttsInstance = tts;
263
+
264
+ __weak typeof(self) weakSelf = self;
265
+ self.ttsInstance.onLastUtteranceFinished = ^{
266
+ __strong typeof(weakSelf) strongSelf = weakSelf;
267
+ if (!strongSelf || !strongSelf.hasListeners) return;
268
+ dispatch_async(dispatch_get_main_queue(), ^{
269
+ [strongSelf sendEventWithName:@"onFinishedSpeaking" body:@{}];
270
+ });
271
+ };
272
+
273
+ resolve(@"TTS initialized");
274
+ });
224
275
  });
225
276
  });
226
277
  }
@@ -317,6 +317,29 @@ SWIFT_CLASS("_TtC10DavoiceTTS25DaVoiceAudioRoutingConfig")
317
317
  - (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
318
318
  @end
319
319
 
320
+ @class AVAudioSession;
321
+ /// Echo cancellation for iPhones WITHOUT Apple’s session-level echo-cancelled
322
+ /// input (<code>AVAudioSession.isEchoCancelledInputAvailable</code>, iOS 18.2+ on
323
+ /// supported hardware). On those devices AEC only exists inside an
324
+ /// AVAudioEngine with voice processing on, and it only cancels audio played
325
+ /// through that same engine – so TTS must play through the engine whose mic
326
+ /// input the listener (wake word) hears. See pocketTTS/AECSupportIOS.md.
327
+ /// Nothing here runs on devices WITH session-level AEC, or when AEC isn’t
328
+ /// requested: every caller then takes its exact pre-existing path.
329
+ SWIFT_CLASS("_TtC10DavoiceTTS16DaVoiceLegacyAEC")
330
+ @interface DaVoiceLegacyAEC : NSObject
331
+ /// Kill switch for the old-iPhone fallback (default true).
332
+ SWIFT_CLASS_PROPERTY(@property (nonatomic, class) BOOL isEnabled;)
333
+ + (BOOL)isEnabled SWIFT_WARN_UNUSED_RESULT;
334
+ + (void)setIsEnabled:(BOOL)newValue;
335
+ /// True when this device/OS offers session-level AEC. Sticky: once seen
336
+ /// true in this process it stays true, so a transient route/category where
337
+ /// iOS reports it unavailable can never switch a newer iPhone onto the
338
+ /// fallback path.
339
+ + (BOOL)deviceHasSessionLevelAEC:(AVAudioSession * _Nonnull)session SWIFT_WARN_UNUSED_RESULT;
340
+ - (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
341
+ @end
342
+
320
343
  @class NSURL;
321
344
  @class NSUUID;
322
345
  @class AVAudioPCMBuffer;