react-native-davoice-tts 1.0.255 → 1.0.256

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 (18) hide show
  1. package/TTSRNBridge.podspec +1 -1
  2. package/ios/TTSRNBridge/DavoiceTTS.xcframework/Info.plist +5 -5
  3. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/DavoiceTTS +0 -0
  4. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.abi.json +1728 -1728
  5. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.private.swiftinterface +12 -12
  6. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.swiftinterface +12 -12
  7. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/DavoiceTTS +0 -0
  8. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.abi.json +3005 -3005
  9. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +12 -12
  10. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.swiftinterface +12 -12
  11. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.abi.json +3005 -3005
  12. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +12 -12
  13. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +12 -12
  14. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeDirectory +0 -0
  15. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeRequirements-1 +0 -0
  16. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeResources +24 -24
  17. package/package.json +1 -1
  18. package/speech/index.ts +48 -15
@@ -14,6 +14,18 @@ import _StringProcessing
14
14
  import _SwiftConcurrencyShims
15
15
  import onnxruntime_objc
16
16
  import phonemes
17
+ public typealias EngineSchedule = (_ url: Foundation.URL, _ onDone: @escaping () -> Swift.Void) -> Swift.Bool
18
+ public typealias IsEngineReady = () -> Swift.Bool
19
+ public typealias useOnlyEnginePlayback = () -> Swift.Bool
20
+ public typealias StopEnginePlayback = () -> Swift.Void
21
+ public typealias CurrentEngineProvider = () -> AVFAudio.AVAudioEngine?
22
+ public enum AudioPlaybackHook {
23
+ public static var engineScheduleFile: DavoiceTTS.EngineSchedule?
24
+ public static var isEngineReady: DavoiceTTS.IsEngineReady?
25
+ public static var useOnlyEnginePlayback: DavoiceTTS.useOnlyEnginePlayback?
26
+ public static var stopEnginePlayback: DavoiceTTS.StopEnginePlayback?
27
+ public static var currentEngine: DavoiceTTS.CurrentEngineProvider?
28
+ }
17
29
  @objc public protocol STTDelegate {
18
30
  @objc func stt(_ stt: DavoiceTTS.STT, didEmitEvent name: Swift.String, body: [Swift.String : Any]?)
19
31
  }
@@ -75,15 +87,3 @@ import phonemes
75
87
  @objc final public func playWav(_ url: Foundation.URL, markAsLastUtterance: Swift.Bool = true)
76
88
  @objc final public func playBuffer(_ buffer: AVFAudio.AVAudioPCMBuffer, markAsLastUtterance: Swift.Bool = true)
77
89
  }
78
- public typealias EngineSchedule = (_ url: Foundation.URL, _ onDone: @escaping () -> Swift.Void) -> Swift.Bool
79
- public typealias IsEngineReady = () -> Swift.Bool
80
- public typealias useOnlyEnginePlayback = () -> Swift.Bool
81
- public typealias StopEnginePlayback = () -> Swift.Void
82
- public typealias CurrentEngineProvider = () -> AVFAudio.AVAudioEngine?
83
- public enum AudioPlaybackHook {
84
- public static var engineScheduleFile: DavoiceTTS.EngineSchedule?
85
- public static var isEngineReady: DavoiceTTS.IsEngineReady?
86
- public static var useOnlyEnginePlayback: DavoiceTTS.useOnlyEnginePlayback?
87
- public static var stopEnginePlayback: DavoiceTTS.StopEnginePlayback?
88
- public static var currentEngine: DavoiceTTS.CurrentEngineProvider?
89
- }
@@ -14,6 +14,18 @@ import _StringProcessing
14
14
  import _SwiftConcurrencyShims
15
15
  import onnxruntime_objc
16
16
  import phonemes
17
+ public typealias EngineSchedule = (_ url: Foundation.URL, _ onDone: @escaping () -> Swift.Void) -> Swift.Bool
18
+ public typealias IsEngineReady = () -> Swift.Bool
19
+ public typealias useOnlyEnginePlayback = () -> Swift.Bool
20
+ public typealias StopEnginePlayback = () -> Swift.Void
21
+ public typealias CurrentEngineProvider = () -> AVFAudio.AVAudioEngine?
22
+ public enum AudioPlaybackHook {
23
+ public static var engineScheduleFile: DavoiceTTS.EngineSchedule?
24
+ public static var isEngineReady: DavoiceTTS.IsEngineReady?
25
+ public static var useOnlyEnginePlayback: DavoiceTTS.useOnlyEnginePlayback?
26
+ public static var stopEnginePlayback: DavoiceTTS.StopEnginePlayback?
27
+ public static var currentEngine: DavoiceTTS.CurrentEngineProvider?
28
+ }
17
29
  @objc public protocol STTDelegate {
18
30
  @objc func stt(_ stt: DavoiceTTS.STT, didEmitEvent name: Swift.String, body: [Swift.String : Any]?)
19
31
  }
@@ -75,15 +87,3 @@ import phonemes
75
87
  @objc final public func playWav(_ url: Foundation.URL, markAsLastUtterance: Swift.Bool = true)
76
88
  @objc final public func playBuffer(_ buffer: AVFAudio.AVAudioPCMBuffer, markAsLastUtterance: Swift.Bool = true)
77
89
  }
78
- public typealias EngineSchedule = (_ url: Foundation.URL, _ onDone: @escaping () -> Swift.Void) -> Swift.Bool
79
- public typealias IsEngineReady = () -> Swift.Bool
80
- public typealias useOnlyEnginePlayback = () -> Swift.Bool
81
- public typealias StopEnginePlayback = () -> Swift.Void
82
- public typealias CurrentEngineProvider = () -> AVFAudio.AVAudioEngine?
83
- public enum AudioPlaybackHook {
84
- public static var engineScheduleFile: DavoiceTTS.EngineSchedule?
85
- public static var isEngineReady: DavoiceTTS.IsEngineReady?
86
- public static var useOnlyEnginePlayback: DavoiceTTS.useOnlyEnginePlayback?
87
- public static var stopEnginePlayback: DavoiceTTS.StopEnginePlayback?
88
- public static var currentEngine: DavoiceTTS.CurrentEngineProvider?
89
- }
@@ -14,11 +14,11 @@
14
14
  </data>
15
15
  <key>Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.abi.json</key>
16
16
  <data>
17
- f7N4jI+WXib0a9+L4aFqHkbjA3Y=
17
+ 3RAZZqjPN6AsMS8CRPYam5UrI+Q=
18
18
  </data>
19
19
  <key>Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface</key>
20
20
  <data>
21
- uXsP9gnz1xzAaRo2eLoIl5JQ3VY=
21
+ 4O+ZELfFqgN6Wieq1IiRQfAtoN4=
22
22
  </data>
23
23
  <key>Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.swiftdoc</key>
24
24
  <data>
@@ -26,19 +26,19 @@
26
26
  </data>
27
27
  <key>Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.swiftinterface</key>
28
28
  <data>
29
- uXsP9gnz1xzAaRo2eLoIl5JQ3VY=
29
+ 4O+ZELfFqgN6Wieq1IiRQfAtoN4=
30
30
  </data>
31
31
  <key>Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.swiftmodule</key>
32
32
  <data>
33
- Swgw9eGnnFVxOIl5VEEdlXTultM=
33
+ INJcQbxf4lAuyKTlVvVmR2cNZaM=
34
34
  </data>
35
35
  <key>Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.abi.json</key>
36
36
  <data>
37
- f7N4jI+WXib0a9+L4aFqHkbjA3Y=
37
+ 3RAZZqjPN6AsMS8CRPYam5UrI+Q=
38
38
  </data>
39
39
  <key>Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface</key>
40
40
  <data>
41
- ZQ//BRCMXbUeGU+SHLgs9vdg3gI=
41
+ 1Vb2U866a0w0XTRJKjUPBKyutls=
42
42
  </data>
43
43
  <key>Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.swiftdoc</key>
44
44
  <data>
@@ -46,11 +46,11 @@
46
46
  </data>
47
47
  <key>Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.swiftinterface</key>
48
48
  <data>
49
- ZQ//BRCMXbUeGU+SHLgs9vdg3gI=
49
+ 1Vb2U866a0w0XTRJKjUPBKyutls=
50
50
  </data>
51
51
  <key>Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.swiftmodule</key>
52
52
  <data>
53
- Wb0CH+d5Rt+B/fW1YFQ4KFp3CkQ=
53
+ +9dEdU5i48FoqSKVckzAEJMNdIc=
54
54
  </data>
55
55
  <key>Modules/module.modulemap</key>
56
56
  <data>
@@ -74,22 +74,22 @@
74
74
  <dict>
75
75
  <key>hash</key>
76
76
  <data>
77
- f7N4jI+WXib0a9+L4aFqHkbjA3Y=
77
+ 3RAZZqjPN6AsMS8CRPYam5UrI+Q=
78
78
  </data>
79
79
  <key>hash2</key>
80
80
  <data>
81
- lhKit0no618yBgiAOzE/KbAwrp3qsphrs6kySop747M=
81
+ tJBTb1sJo1EzXnSMFMyFRZF5Mf/pWCw0spR0l6AoO6s=
82
82
  </data>
83
83
  </dict>
84
84
  <key>Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface</key>
85
85
  <dict>
86
86
  <key>hash</key>
87
87
  <data>
88
- uXsP9gnz1xzAaRo2eLoIl5JQ3VY=
88
+ 4O+ZELfFqgN6Wieq1IiRQfAtoN4=
89
89
  </data>
90
90
  <key>hash2</key>
91
91
  <data>
92
- aAIibkQumUq3CC2187V6O9u81lZQtF+Zo062pC65QHw=
92
+ m6+AXAvSKhaIawhOn0Oa+LfqZr0mwnH+e49WljlXBDQ=
93
93
  </data>
94
94
  </dict>
95
95
  <key>Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.swiftdoc</key>
@@ -107,44 +107,44 @@
107
107
  <dict>
108
108
  <key>hash</key>
109
109
  <data>
110
- uXsP9gnz1xzAaRo2eLoIl5JQ3VY=
110
+ 4O+ZELfFqgN6Wieq1IiRQfAtoN4=
111
111
  </data>
112
112
  <key>hash2</key>
113
113
  <data>
114
- aAIibkQumUq3CC2187V6O9u81lZQtF+Zo062pC65QHw=
114
+ m6+AXAvSKhaIawhOn0Oa+LfqZr0mwnH+e49WljlXBDQ=
115
115
  </data>
116
116
  </dict>
117
117
  <key>Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.swiftmodule</key>
118
118
  <dict>
119
119
  <key>hash</key>
120
120
  <data>
121
- Swgw9eGnnFVxOIl5VEEdlXTultM=
121
+ INJcQbxf4lAuyKTlVvVmR2cNZaM=
122
122
  </data>
123
123
  <key>hash2</key>
124
124
  <data>
125
- oOwDygBnum5lqC5hoFBQaoYemQOzZjsbr+FlcYF7pHc=
125
+ TVZZVoeIqGe9BS6dOJAJ6/MMUEQQuiCMAA4f9OcB+b0=
126
126
  </data>
127
127
  </dict>
128
128
  <key>Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.abi.json</key>
129
129
  <dict>
130
130
  <key>hash</key>
131
131
  <data>
132
- f7N4jI+WXib0a9+L4aFqHkbjA3Y=
132
+ 3RAZZqjPN6AsMS8CRPYam5UrI+Q=
133
133
  </data>
134
134
  <key>hash2</key>
135
135
  <data>
136
- lhKit0no618yBgiAOzE/KbAwrp3qsphrs6kySop747M=
136
+ tJBTb1sJo1EzXnSMFMyFRZF5Mf/pWCw0spR0l6AoO6s=
137
137
  </data>
138
138
  </dict>
139
139
  <key>Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface</key>
140
140
  <dict>
141
141
  <key>hash</key>
142
142
  <data>
143
- ZQ//BRCMXbUeGU+SHLgs9vdg3gI=
143
+ 1Vb2U866a0w0XTRJKjUPBKyutls=
144
144
  </data>
145
145
  <key>hash2</key>
146
146
  <data>
147
- Hw+bYIfvYYhjCYfipeFH/tzcwytcA0GefnHPjhJvdWc=
147
+ xnT9sHQ+AlnAVwienpdc3CibbdtRRl60kSp3a3bXvKw=
148
148
  </data>
149
149
  </dict>
150
150
  <key>Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.swiftdoc</key>
@@ -162,22 +162,22 @@
162
162
  <dict>
163
163
  <key>hash</key>
164
164
  <data>
165
- ZQ//BRCMXbUeGU+SHLgs9vdg3gI=
165
+ 1Vb2U866a0w0XTRJKjUPBKyutls=
166
166
  </data>
167
167
  <key>hash2</key>
168
168
  <data>
169
- Hw+bYIfvYYhjCYfipeFH/tzcwytcA0GefnHPjhJvdWc=
169
+ xnT9sHQ+AlnAVwienpdc3CibbdtRRl60kSp3a3bXvKw=
170
170
  </data>
171
171
  </dict>
172
172
  <key>Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.swiftmodule</key>
173
173
  <dict>
174
174
  <key>hash</key>
175
175
  <data>
176
- Wb0CH+d5Rt+B/fW1YFQ4KFp3CkQ=
176
+ +9dEdU5i48FoqSKVckzAEJMNdIc=
177
177
  </data>
178
178
  <key>hash2</key>
179
179
  <data>
180
- FDf9Qwlm9ywiwgD1CrwyWkjfjdbnoHLObwQ6w5KGbJA=
180
+ 8yWt+N+RFv6qWVK5ez+zZef+TsiN7MStzeI9jMjZ34E=
181
181
  </data>
182
182
  </dict>
183
183
  <key>Modules/module.modulemap</key>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-davoice-tts",
3
- "version": "1.0.255",
3
+ "version": "1.0.256",
4
4
  "description": "tts library for React Native",
5
5
  "main": "tts/index.js",
6
6
  "types": "tts/index.d.ts",
package/speech/index.ts CHANGED
@@ -551,45 +551,78 @@ class Speech {
551
551
  return NativeTTS.stopSpeaking();
552
552
  }
553
553
 
554
- // --- NEW: TTS passthroughs for external audio ---
555
- /** Queue a WAV file (local path, file:// URL, or require() asset). */
554
+ // ADD near your other TTS queue fields (DO NOT remove existing ones)
555
+ private wavChain: Promise<void> = Promise.resolve();
556
+
557
+ // ADD helper (minimal, uses existing onFinishedSpeaking event)
558
+ private _playWavAndWait(realPath: string, markAsLast: boolean, timeoutMs = 10000) {
559
+ return new Promise<void>((resolve, reject) => {
560
+ this.ttsPendingResolve = resolve; // reuse existing resolver + event
561
+ this.ttsPendingTimeout = setTimeout(() => {
562
+ this.ttsPendingResolve = null;
563
+ reject(new Error('WAV timeout waiting for onFinishedSpeaking'));
564
+ }, timeoutMs);
565
+
566
+ try {
567
+ // Prefer unified iOS bridge if present
568
+ if (Platform.OS === 'ios' && NativeSpeech?.playWav) {
569
+ (NativeSpeech as any).playWav(realPath, markAsLast);
570
+ return;
571
+ }
572
+ if (!NativeTTS?.playWav) throw new Error('playWav not available on this platform.');
573
+ (NativeTTS as any).playWav(realPath, markAsLast);
574
+ } catch (e) {
575
+ if (this.ttsPendingTimeout) { clearTimeout(this.ttsPendingTimeout); this.ttsPendingTimeout = null; }
576
+ this.ttsPendingResolve = null;
577
+ reject(e as any);
578
+ }
579
+ });
580
+ }
581
+
556
582
  async playWav(pathOrURL: any, markAsLast = true) {
557
- // NEW: resolve require() assets to actual file path/URI
583
+ // KEEP ALL YOUR EXISTING LOGGING + resolveAssetSource LOGIC
558
584
  console.log('[Speech.playWav] called with:', pathOrURL, '| type:', typeof pathOrURL);
559
- //const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource').default;
560
585
 
561
586
  const asset = resolveAssetSource(pathOrURL);
562
587
  console.log('[Speech.playWav] resolveAssetSource ->', asset);
563
588
 
564
- let realPath = asset?.uri ?? pathOrURL; // fallback keeps string path intact
589
+ let realPath = asset?.uri ?? pathOrURL;
565
590
  console.log('[Speech.playWav] resolved realPath:', realPath);
566
591
 
567
- // ✅ Coerce to string explicitly
568
592
  if (typeof realPath !== 'string') {
569
593
  realPath = String(realPath);
570
594
  console.log('[Speech.playWav] converted ?? realPath:', realPath);
571
595
  }
572
-
596
+
573
597
  console.log('[Speech.playWav] before checking ios realPath:', realPath);
574
598
 
575
- // Prefer unified iOS bridge if present
599
+ // IMPORTANT: separate logic per platform + queue only when markAsLast=true
600
+ this.ensureListeners();
601
+
602
+ if (markAsLast) {
603
+ // Waitable: serialize on its own queue (separate from speak)
604
+ this.wavChain = this.wavChain.then(() => this._playWavAndWait(realPath, true));
605
+ return this.wavChain;
606
+ }
607
+
608
+ // Fire-and-forget (cannot await because native will not emit completion)
576
609
  if (Platform.OS === 'ios' && NativeSpeech?.playWav) {
577
- return NativeSpeech.playWav(realPath, markAsLast);
610
+ return (NativeSpeech as any).playWav(realPath, false);
578
611
  }
612
+
579
613
  console.log('[Speech.playWav] after checking ios realPath:', realPath);
580
- console.log('[Speech.playWav] after checking ios realPath:', typeof(realPath));
614
+ console.log('[Speech.playWav] after checking ios realPath:', typeof realPath);
581
615
 
582
- // Fallback: direct TTS bridge (Android + iOS fallback)
583
616
  if (!NativeTTS?.playWav) {
584
617
  console.log('[Speech.playWav] NativeTTS:', NativeTTS);
585
- if (NativeTTS)
586
- console.log('[Speech.playWav] NativeTTS.playWav :', NativeTTS.playWav);
618
+ if (NativeTTS) console.log('[Speech.playWav] NativeTTS.playWav :', NativeTTS.playWav);
587
619
  throw new Error('playWav not available on this platform.');
588
620
  }
589
- console.log('[Speech.playWav] calling NativeTTS.playWav with type of realPath:', typeof(realPath));
590
- return NativeTTS.playWav(realPath, markAsLast);
621
+ console.log('[Speech.playWav] calling NativeTTS.playWav with type of realPath:', typeof realPath);
622
+ return (NativeTTS as any).playWav(realPath, false);
591
623
  }
592
624
 
625
+
593
626
  // /** Queue a WAV file (local path or file:// URL). Routed via AEC path, queued with speak(). */
594
627
  // async playWav(pathOrURL: string, markAsLast = true) {
595
628
  // // Prefer unified iOS bridge if present