react-native-davoice-tts 1.0.367 → 1.0.369

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/android/src/main/java/com/davoice/stt/rn/STTModule.kt +12 -10
  6. package/android/src/main/java/com/davoice/tts/rn/DaVoiceTTSBridge.java +16 -6
  7. package/android/src/main/libs/MyLibrary-release.aar +0 -0
  8. package/ios/SpeechBridge/SpeechBridge.m +34 -22
  9. package/ios/TTSRNBridge/DaVoiceTTSBridge.m +15 -6
  10. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/DavoiceTTS +0 -0
  11. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.abi.json +432 -418
  12. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.private.swiftinterface +1 -1
  13. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.swiftinterface +1 -1
  14. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/DavoiceTTS +0 -0
  15. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.abi.json +432 -418
  16. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +1 -1
  17. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.swiftinterface +1 -1
  18. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.abi.json +432 -418
  19. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +1 -1
  20. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +1 -1
  21. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeDirectory +0 -0
  22. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeRequirements-1 +0 -0
  23. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeResources +24 -24
  24. package/package.json +1 -1
  25. package/speech/index.ts +116 -63
  26. package/stt/index.ts +8 -1
  27. package/tts/DaVoiceTTSBridge.js +7 -1
@@ -197,7 +197,7 @@ public struct SpeakerVerificationConfig : Swift.Codable {
197
197
  public var logLevel: DavoiceTTS.SVLogLevel
198
198
  public init(from decoder: any Swift.Decoder) throws
199
199
  public func encode(to encoder: any Swift.Encoder) throws
200
- public init(modelPath: Swift.String, sampleRate: Swift.Int = 16_000, numMelBins: Swift.Int = 80, cmn: Swift.Bool = true, frameLengthMs: Swift.Float = 25.0, frameShiftMs: Swift.Float = 10.0, nFFT: Swift.Int = 512, decisionThreshold: Swift.Float = 0.35, expectedLayoutBDT: Swift.Bool = false, frameSize: Swift.Int = 1280, tailSeconds: Swift.Float = 2.0, maxTailSeconds: Swift.Float = 3.0, meanComboEnabled: Swift.Bool = true, meanComboMaxK: Swift.Int = 3, meanComboMaxTotal: Swift.Int = 2000, logLevel: DavoiceTTS.SVLogLevel = .debug)
200
+ public init(modelPath: Swift.String, sampleRate: Swift.Int = 16_000, numMelBins: Swift.Int = 80, cmn: Swift.Bool = true, frameLengthMs: Swift.Float = 25.0, frameShiftMs: Swift.Float = 10.0, nFFT: Swift.Int = 512, decisionThreshold: Swift.Float = 0.35, expectedLayoutBDT: Swift.Bool = false, frameSize: Swift.Int = 1280, tailSeconds: Swift.Float = 2.0, maxTailSeconds: Swift.Float = 3.0, meanComboEnabled: Swift.Bool = true, meanComboMaxK: Swift.Int = 3, meanComboMaxTotal: Swift.Int = 2000, logLevel: DavoiceTTS.SVLogLevel = .off)
201
201
  }
202
202
  public struct SpeakerEnrollment : Swift.Codable {
203
203
  public let enrollmentId: Swift.String
@@ -197,7 +197,7 @@ public struct SpeakerVerificationConfig : Swift.Codable {
197
197
  public var logLevel: DavoiceTTS.SVLogLevel
198
198
  public init(from decoder: any Swift.Decoder) throws
199
199
  public func encode(to encoder: any Swift.Encoder) throws
200
- public init(modelPath: Swift.String, sampleRate: Swift.Int = 16_000, numMelBins: Swift.Int = 80, cmn: Swift.Bool = true, frameLengthMs: Swift.Float = 25.0, frameShiftMs: Swift.Float = 10.0, nFFT: Swift.Int = 512, decisionThreshold: Swift.Float = 0.35, expectedLayoutBDT: Swift.Bool = false, frameSize: Swift.Int = 1280, tailSeconds: Swift.Float = 2.0, maxTailSeconds: Swift.Float = 3.0, meanComboEnabled: Swift.Bool = true, meanComboMaxK: Swift.Int = 3, meanComboMaxTotal: Swift.Int = 2000, logLevel: DavoiceTTS.SVLogLevel = .debug)
200
+ public init(modelPath: Swift.String, sampleRate: Swift.Int = 16_000, numMelBins: Swift.Int = 80, cmn: Swift.Bool = true, frameLengthMs: Swift.Float = 25.0, frameShiftMs: Swift.Float = 10.0, nFFT: Swift.Int = 512, decisionThreshold: Swift.Float = 0.35, expectedLayoutBDT: Swift.Bool = false, frameSize: Swift.Int = 1280, tailSeconds: Swift.Float = 2.0, maxTailSeconds: Swift.Float = 3.0, meanComboEnabled: Swift.Bool = true, meanComboMaxK: Swift.Int = 3, meanComboMaxTotal: Swift.Int = 2000, logLevel: DavoiceTTS.SVLogLevel = .off)
201
201
  }
202
202
  public struct SpeakerEnrollment : Swift.Codable {
203
203
  public let enrollmentId: Swift.String
@@ -14,11 +14,11 @@
14
14
  </data>
15
15
  <key>Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.abi.json</key>
16
16
  <data>
17
- ru7p+bUKnIS+HG5H0Pk4ci+5Jxg=
17
+ EphxVlJED59kbqQ3or966ytYg6I=
18
18
  </data>
19
19
  <key>Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface</key>
20
20
  <data>
21
- nJGa9a3X0P/C5O0dZf1NYhjqyhc=
21
+ rBAXQ5p1nFznE9lDB2fjnDpG4G0=
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
- nJGa9a3X0P/C5O0dZf1NYhjqyhc=
29
+ rBAXQ5p1nFznE9lDB2fjnDpG4G0=
30
30
  </data>
31
31
  <key>Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.swiftmodule</key>
32
32
  <data>
33
- mG5zpUzD0Dj71BTZ8Lvunb7lkbM=
33
+ k+GkN20de5GN4frQgQ6L7c6eDi8=
34
34
  </data>
35
35
  <key>Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.abi.json</key>
36
36
  <data>
37
- ru7p+bUKnIS+HG5H0Pk4ci+5Jxg=
37
+ EphxVlJED59kbqQ3or966ytYg6I=
38
38
  </data>
39
39
  <key>Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface</key>
40
40
  <data>
41
- KW3zq20fxSNKp3z3d7TcznPWiP4=
41
+ /JI1t6r6wr/zuwq4TewxkVJ6RqI=
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
- KW3zq20fxSNKp3z3d7TcznPWiP4=
49
+ /JI1t6r6wr/zuwq4TewxkVJ6RqI=
50
50
  </data>
51
51
  <key>Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.swiftmodule</key>
52
52
  <data>
53
- UukBUaorNvJ3swwENgV9QE64egI=
53
+ s5aHOuj8F/LwF2Akwz9hR/citzU=
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
- ru7p+bUKnIS+HG5H0Pk4ci+5Jxg=
77
+ EphxVlJED59kbqQ3or966ytYg6I=
78
78
  </data>
79
79
  <key>hash2</key>
80
80
  <data>
81
- jDpKOzrNa5k/cHoG7rjXaJsi6TNjU6jd/SQWSe/FrAY=
81
+ tpMM/tJELbY6pCkJOrEr+W2aXCakvJPn0wgv8Eu6+NE=
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
- nJGa9a3X0P/C5O0dZf1NYhjqyhc=
88
+ rBAXQ5p1nFznE9lDB2fjnDpG4G0=
89
89
  </data>
90
90
  <key>hash2</key>
91
91
  <data>
92
- 0iPH5zlEtAJ3NTDgWPDwrXa3fCLwpTV8+wfrCWoLQsc=
92
+ nlQICdEdKlQdQSj0c53wlHehS303Jz9TtL478iyRC7w=
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
- nJGa9a3X0P/C5O0dZf1NYhjqyhc=
110
+ rBAXQ5p1nFznE9lDB2fjnDpG4G0=
111
111
  </data>
112
112
  <key>hash2</key>
113
113
  <data>
114
- 0iPH5zlEtAJ3NTDgWPDwrXa3fCLwpTV8+wfrCWoLQsc=
114
+ nlQICdEdKlQdQSj0c53wlHehS303Jz9TtL478iyRC7w=
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
- mG5zpUzD0Dj71BTZ8Lvunb7lkbM=
121
+ k+GkN20de5GN4frQgQ6L7c6eDi8=
122
122
  </data>
123
123
  <key>hash2</key>
124
124
  <data>
125
- 5rkxfeXBgmtWNUJKirhDCCabcOxhlPoY8cY1GzYuUag=
125
+ 22MvGYtDcyMzjmwqT0Guh+nps5GkZPy9eXyytCuIiEo=
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
- ru7p+bUKnIS+HG5H0Pk4ci+5Jxg=
132
+ EphxVlJED59kbqQ3or966ytYg6I=
133
133
  </data>
134
134
  <key>hash2</key>
135
135
  <data>
136
- jDpKOzrNa5k/cHoG7rjXaJsi6TNjU6jd/SQWSe/FrAY=
136
+ tpMM/tJELbY6pCkJOrEr+W2aXCakvJPn0wgv8Eu6+NE=
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
- KW3zq20fxSNKp3z3d7TcznPWiP4=
143
+ /JI1t6r6wr/zuwq4TewxkVJ6RqI=
144
144
  </data>
145
145
  <key>hash2</key>
146
146
  <data>
147
- Zry/ZX+dhZk8czEu6juDVYa+TcZniSIP3m4nuPxQW8k=
147
+ sCC9UgvU8GsKTggUO2sH5+KUq5Zo7YQC111Md4BOvbw=
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
- KW3zq20fxSNKp3z3d7TcznPWiP4=
165
+ /JI1t6r6wr/zuwq4TewxkVJ6RqI=
166
166
  </data>
167
167
  <key>hash2</key>
168
168
  <data>
169
- Zry/ZX+dhZk8czEu6juDVYa+TcZniSIP3m4nuPxQW8k=
169
+ sCC9UgvU8GsKTggUO2sH5+KUq5Zo7YQC111Md4BOvbw=
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
- UukBUaorNvJ3swwENgV9QE64egI=
176
+ s5aHOuj8F/LwF2Akwz9hR/citzU=
177
177
  </data>
178
178
  <key>hash2</key>
179
179
  <data>
180
- DrzWlfpisKxpcKHvEzqlPqWvhtauis/mAk5jMK5SZLk=
180
+ adGpsmHrpNMWvuGe8sfz5CyhGoTH7pghBUUDPvkMjC8=
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.367",
3
+ "version": "1.0.369",
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
@@ -6,7 +6,7 @@ import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource'
6
6
  const AssetRegistry = require('react-native/Libraries/Image/AssetRegistry');
7
7
 
8
8
  // -------------------- VERBOSE LOGGING --------------------
9
- const VERBOSE = true;
9
+ const VERBOSE = false;
10
10
  const PFX = '[SpeechJS]';
11
11
  function ts() {
12
12
  const d = new Date();
@@ -19,7 +19,12 @@ function dbg(...args: any[]) {
19
19
  }
20
20
  function dbgErr(...args: any[]) {
21
21
  // eslint-disable-next-line no-console
22
- console.log(ts(), PFX, '❌', ...args);
22
+ console.error(ts(), PFX, '❌', ...args);
23
+ }
24
+ function dbgNotice(...args: any[]) {
25
+ // Pause/unpause timeouts are bounded control-flow outcomes, not errors.
26
+ // eslint-disable-next-line no-console
27
+ console.log(ts(), PFX, 'ℹ️', ...args);
23
28
  }
24
29
 
25
30
  function safeJson(x: any) {
@@ -34,6 +39,42 @@ function sleep(ms: number) {
34
39
  return new Promise<void>((r) => setTimeout(r, ms));
35
40
  }
36
41
 
42
+ // Android's pauseSpeechRecognitionLite/unPauseSpeechRecognitionLite native callbacks have
43
+ // no native-JS-visible timeout contract of their own (unlike iOS's ...LiteAsync). This
44
+ // guarantees the wrapping promise always settles: on timeout it logs and resolves with
45
+ // undefined rather than rejecting, so callers that never expected this call to throw don't
46
+ // suddenly start seeing exceptions - the only change is a bounded wait instead of an
47
+ // unbounded one.
48
+ function androidCallbackWithTimeout<T>(
49
+ invoke: (done: (value: T) => void) => void,
50
+ timeoutMs: number,
51
+ label: string,
52
+ ): Promise<T | undefined> {
53
+ return new Promise<T | undefined>((resolve) => {
54
+ let settled = false;
55
+ const timer = setTimeout(() => {
56
+ if (settled) return;
57
+ settled = true;
58
+ dbgNotice(`IMPORTANT: ${label} reached timeout - please note this is not a bug`, { timeoutMs });
59
+ resolve(undefined);
60
+ }, timeoutMs);
61
+ try {
62
+ invoke((value) => {
63
+ if (settled) return;
64
+ settled = true;
65
+ clearTimeout(timer);
66
+ resolve(value);
67
+ });
68
+ } catch (e) {
69
+ if (settled) return;
70
+ settled = true;
71
+ clearTimeout(timer);
72
+ dbgErr(`${label} threw before native callback`, String(e));
73
+ resolve(undefined);
74
+ }
75
+ });
76
+ }
77
+
37
78
  let speechOpSeq = 0;
38
79
  const PROBABLY_GPT_MISTAKE = false;
39
80
  function nextSpeechOpId(prefix: string) {
@@ -449,8 +490,8 @@ class Speech {
449
490
  }
450
491
  // Init TTS
451
492
  const modelExt = this.resolveModelExt(cfg.model);
452
- console.log('[MODELDBG] initAllRemoteSTT.modelPath (resolved)=', modelPath);
453
- console.log('[MODELDBG] initAllRemoteSTT.modelExt (resolved)=', modelExt);
493
+ dbg('[MODELDBG] initAllRemoteSTT.modelPath (resolved)=', modelPath);
494
+ dbg('[MODELDBG] initAllRemoteSTT.modelExt (resolved)=', modelExt);
454
495
  await NativeTTS.initTTS({ model: modelPath, modelExt });
455
496
  await sleep(500);
456
497
  }
@@ -488,13 +529,13 @@ class Speech {
488
529
 
489
530
  dbgModel(label: string, model: any) {
490
531
  try {
491
- console.log(`[MODELDBG] ${label} typeof=`, typeof model, ' value=', model);
532
+ dbg(`[MODELDBG] ${label} typeof=`, typeof model, ' value=', model);
492
533
  try {
493
534
  const asset = resolveAssetSource(model);
494
- console.log(`[MODELDBG] ${label} resolveAssetSource=`, asset);
495
- if (asset?.uri) console.log(`[MODELDBG] ${label} asset.uri=`, asset.uri);
535
+ dbg(`[MODELDBG] ${label} resolveAssetSource=`, asset);
536
+ if (asset?.uri) dbg(`[MODELDBG] ${label} asset.uri=`, asset.uri);
496
537
  } catch (e) {
497
- console.log(`[MODELDBG] ${label} resolveAssetSource threw:`, String(e));
538
+ dbg(`[MODELDBG] ${label} resolveAssetSource threw:`, String(e));
498
539
  }
499
540
  } catch {}
500
541
  }
@@ -536,7 +577,7 @@ class Speech {
536
577
  this.wavChain = Promise.resolve();
537
578
 
538
579
  const modelPath = this.resolveModelToPath(opts.model);
539
- console.log('[MODELDBG] initAll.modelPath (resolved)=', modelPath);
580
+ dbg('[MODELDBG] initAll.modelPath (resolved)=', modelPath);
540
581
 
541
582
  this.lastLocale = opts.locale;
542
583
  this.lastModel = modelPath;
@@ -607,7 +648,7 @@ class Speech {
607
648
 
608
649
  // Init TTS
609
650
  const modelExt = this.resolveModelExt(opts.model);
610
- console.log('[MODELDBG] initAll.modelExt (resolved)=', modelExt);
651
+ dbg('[MODELDBG] initAll.modelExt (resolved)=', modelExt);
611
652
  await NativeTTS.initTTS({ model: modelPath, modelExt });
612
653
  this.hasCompletedFullInit = true;
613
654
  this.hasCompletedTtsInit = true;
@@ -795,10 +836,15 @@ class Speech {
795
836
  return this.start(locale);
796
837
  }
797
838
 
798
- // TODO: CHECK THE NATIVE SIDE DOES NOT REALLY AWAITS
799
- async pauseSpeechRecognition(): Promise<void> {
839
+ // Android: native pauseSpeechRecognitionLite is now bounded internally (~500ms, see
840
+ // STT.kt runPauseResumeSerializedOnMain), so this timeout is a backstop, not the
841
+ // primary fix - it guarantees this promise settles even if the bridge itself stalls.
842
+ async pauseSpeechRecognition(timeoutMs: number = 500): Promise<void> {
800
843
  this.logCall('pauseSpeechRecognitionLite');
801
844
  const startedAt = Date.now();
845
+ const effectiveTimeoutMs = Number.isFinite(timeoutMs) && timeoutMs > 0
846
+ ? Math.min(timeoutMs, 500)
847
+ : 500;
802
848
 
803
849
  const mod: any = Platform.OS === 'ios' ? NativeSpeech : NativeSTT;
804
850
  const fn = mod?.pauseSpeechRecognitionLite;
@@ -810,17 +856,19 @@ class Speech {
810
856
  }
811
857
 
812
858
  if (Platform.OS === 'ios' && typeof mod?.pauseSpeechRecognitionLiteAsync === 'function') {
813
- dbg('[pauseSpeechRecognitionLiteAsync] begin', { ...(opId ? { opId } : {}), timeoutMs: 1500 });
814
- const result = await mod.pauseSpeechRecognitionLiteAsync(1500);
859
+ dbg('[pauseSpeechRecognitionLiteAsync] begin', { ...(opId ? { opId } : {}), timeoutMs: 500 });
860
+ const result = await mod.pauseSpeechRecognitionLiteAsync(500);
815
861
  dbg('[pauseSpeechRecognitionLiteAsync] resolved', { ...(opId ? { opId } : {}), elapsedMs: Date.now() - startedAt, result });
816
- if (result?.ok === false) dbgErr('pauseSpeechRecognitionLiteAsync failed', result?.reason);
862
+ if (result?.ok === false) {
863
+ dbgNotice('IMPORTANT: pauseSpeechRecognitionLiteAsync reached timeout - please note this is not a bug', result?.reason);
864
+ }
817
865
  return;
818
866
  }
819
867
  if (Platform.OS === 'ios') {
820
868
  await new Promise<void>((resolve, reject) => {
821
869
  try {
822
870
  fn.call(mod, (ok: boolean) => {
823
- if (!ok) dbgErr('pauseSpeechRecognitionLite returned false');
871
+ if (!ok) dbgNotice('IMPORTANT: pauseSpeechRecognitionLite reached timeout - please note this is not a bug');
824
872
  resolve();
825
873
  });
826
874
  } catch (e) {
@@ -830,18 +878,16 @@ class Speech {
830
878
  return;
831
879
  }
832
880
 
833
- await new Promise<void>((resolve, reject) => {
834
- try {
835
- fn.call(mod, async (ok: boolean) => {
836
- if (!ok) dbgErr('pauseSpeechRecognitionLite returned false');
837
- // ✅ ANDROID: small delay before resolving
838
- if (Platform.OS === 'android') await sleep(500);
839
- resolve();
881
+ await androidCallbackWithTimeout<void>(
882
+ (done) => {
883
+ fn.call(mod, (ok: boolean) => {
884
+ if (!ok) dbgNotice('IMPORTANT: pauseSpeechRecognitionLite reached timeout - please note this is not a bug');
885
+ done(undefined);
840
886
  });
841
- } catch (e) {
842
- reject(e as any);
843
- }
844
- });
887
+ },
888
+ effectiveTimeoutMs,
889
+ 'pauseSpeechRecognitionLite',
890
+ );
845
891
  };
846
892
 
847
893
  if (PROBABLY_GPT_MISTAKE) {
@@ -856,10 +902,13 @@ class Speech {
856
902
  async unPauseSpeechRecognition(
857
903
  times: number,
858
904
  preFetchMs: number = 0,
859
- timeoutMs: number = 2500,
905
+ timeoutMs: number = 500,
860
906
  ): Promise<void> {
861
907
  this.logCall('unPauseSpeechRecognitionLite', { times, preFetchMs });
862
908
  const startedAt = Date.now();
909
+ const effectiveTimeoutMs = Number.isFinite(timeoutMs) && timeoutMs > 0
910
+ ? Math.min(timeoutMs, 500)
911
+ : 500;
863
912
 
864
913
  const mod: any = Platform.OS === 'ios' ? NativeSpeech : NativeSTT;
865
914
  const fn = mod?.unPauseSpeechRecognitionLite;
@@ -871,8 +920,8 @@ class Speech {
871
920
  }
872
921
 
873
922
  if (Platform.OS === 'ios' && typeof mod?.unPauseSpeechRecognitionLiteAsync === 'function') {
874
- dbg('[unPauseSpeechRecognitionLiteAsync] begin', { ...(opId ? { opId } : {}), times, preFetchMs, timeoutMs });
875
- const result = await mod.unPauseSpeechRecognitionLiteAsync(times, preFetchMs, timeoutMs);
923
+ dbg('[unPauseSpeechRecognitionLiteAsync] begin', { ...(opId ? { opId } : {}), times, preFetchMs, timeoutMs: effectiveTimeoutMs });
924
+ const result = await mod.unPauseSpeechRecognitionLiteAsync(times, preFetchMs, effectiveTimeoutMs);
876
925
  dbg('[unPauseSpeechRecognitionLiteAsync] resolved', {
877
926
  ...(opId ? { opId } : {}),
878
927
  times,
@@ -880,7 +929,9 @@ class Speech {
880
929
  elapsedMs: Date.now() - startedAt,
881
930
  result,
882
931
  });
883
- if (result?.ok === false) dbgErr('unPauseSpeechRecognitionLiteAsync failed', result?.reason);
932
+ if (result?.ok === false) {
933
+ dbgNotice('IMPORTANT: unPauseSpeechRecognitionLiteAsync reached timeout - please note this is not a bug', result?.reason);
934
+ }
884
935
  return;
885
936
  }
886
937
 
@@ -888,7 +939,7 @@ class Speech {
888
939
  await new Promise<void>((resolve, reject) => {
889
940
  try {
890
941
  const done = (ok: boolean) => {
891
- if (!ok) dbgErr('unPauseSpeechRecognitionLite(times) returned false');
942
+ if (!ok) dbgNotice('IMPORTANT: unPauseSpeechRecognitionLite reached timeout - please note this is not a bug');
892
943
  dbg('[CALL unPauseSpeechRecognitionLite] native callback fired', { times, preFetchMs, ok });
893
944
  resolve();
894
945
  };
@@ -907,23 +958,21 @@ class Speech {
907
958
  });
908
959
  return;
909
960
  }
910
- await new Promise<void>((resolve, reject) => {
911
- try {
912
- const done = async (ok: boolean) => {
913
- if (!ok) dbgErr('unPauseSpeechRecognitionLite(times) returned false');
914
- // ✅ ANDROID: small delay before resolving
915
- if (Platform.OS === 'android') await sleep(500);
916
- resolve();
961
+ await androidCallbackWithTimeout<void>(
962
+ (done) => {
963
+ const nativeDone = (ok: boolean) => {
964
+ if (!ok) dbgNotice('IMPORTANT: unPauseSpeechRecognitionLite reached timeout - please note this is not a bug');
965
+ done(undefined);
917
966
  };
918
967
  if (Platform.OS === 'android' && preFetchMs > 0 && typeof mod?.unPauseSpeechRecognitionLiteWithPreFetch === 'function') {
919
- mod.unPauseSpeechRecognitionLiteWithPreFetch(times, preFetchMs, done);
968
+ mod.unPauseSpeechRecognitionLiteWithPreFetch(times, preFetchMs, nativeDone);
920
969
  return;
921
970
  }
922
- fn.call(mod, times, done);
923
- } catch (e) {
924
- reject(e as any);
925
- }
926
- });
971
+ fn.call(mod, times, nativeDone);
972
+ },
973
+ effectiveTimeoutMs,
974
+ 'unPauseSpeechRecognitionLite',
975
+ );
927
976
  };
928
977
 
929
978
  if (PROBABLY_GPT_MISTAKE) {
@@ -936,15 +985,17 @@ class Speech {
936
985
  }
937
986
  /** Pause mic/STT (Android native; iOS unified if present) */
938
987
  async pauseMicrophone(): Promise<void> {
939
- console.log('[pauseMicrophone] called');
988
+ dbg('[pauseMicrophone] called');
940
989
  this.logCall('pauseMicrophone');
941
990
  // iOS: prefer async first, fallback to callback if missing
942
991
  if (Platform.OS === 'ios' && (NativeSpeech as any)?.pauseMicrophoneAsync) {
943
992
  dbg('IOS [pauseMicrophone] using NativeSpeech.pauseMicrophoneAsync()');
944
993
  try {
945
- const r = await (NativeSpeech as any).pauseMicrophoneAsync(1000);
994
+ const r = await (NativeSpeech as any).pauseMicrophoneAsync(500);
946
995
  dbg('pauseMicrophoneAsync result', r);
947
- if (r?.ok === false) dbgErr('pauseMicrophoneAsync failed', r?.reason);
996
+ if (r?.ok === false) {
997
+ dbgNotice('IMPORTANT: pauseMicrophoneAsync reached timeout - please note this is not a bug', r?.reason);
998
+ }
948
999
  return;
949
1000
  } catch (e) {
950
1001
  dbgErr('IOS [pauseMicrophone] NativeSpeech.pauseMicrophoneAsync() ERROR:', String(e));
@@ -952,7 +1003,7 @@ class Speech {
952
1003
  }
953
1004
  }
954
1005
  if (Platform.OS === 'ios' && NativeSpeech?.pauseMicrophone) {
955
- console.log('IOS [pauseMicrophone] called');
1006
+ dbg('IOS [pauseMicrophone] called');
956
1007
  return new Promise((resolve, reject) => {
957
1008
  try { (NativeSpeech as any).pauseMicrophone(() => resolve()); }
958
1009
  catch (e) { reject(e as any); }
@@ -972,8 +1023,10 @@ class Speech {
972
1023
  if (Platform.OS === 'ios' && (NativeSpeech as any)?.unPauseMicrophoneAsync) {
973
1024
  dbg('IOS [unPauseMicrophone] using NativeSpeech.unPauseMicrophoneAsync()');
974
1025
  try {
975
- const r = await (NativeSpeech as any).unPauseMicrophoneAsync(1000);
976
- if (r?.ok === false) dbgErr('unPauseMicrophone failed', r?.reason);
1026
+ const r = await (NativeSpeech as any).unPauseMicrophoneAsync(500);
1027
+ if (r?.ok === false) {
1028
+ dbgNotice('IMPORTANT: unPauseMicrophoneAsync reached timeout - please note this is not a bug', r?.reason);
1029
+ }
977
1030
  dbg('IOS [unPauseMicrophone] NativeSpeech.unPauseMicrophoneAsync() DONE');
978
1031
  return;
979
1032
  } catch (e) {
@@ -983,14 +1036,14 @@ class Speech {
983
1036
  }
984
1037
 
985
1038
  if (Platform.OS === 'ios' && NativeSpeech?.unPauseMicrophone) {
986
- console.log('IOS [unPauseMicrophone] called');
1039
+ dbg('IOS [unPauseMicrophone] called');
987
1040
  return new Promise((resolve, reject) => {
988
1041
  try { (NativeSpeech as any).unPauseMicrophone(() => resolve()); }
989
1042
  catch (e) { reject(e as any); }
990
1043
  });
991
1044
  }
992
1045
  if (Platform.OS === 'ios')
993
- console.log('IOS [unPauseMicrophone] called without native support');
1046
+ dbg('IOS [unPauseMicrophone] called without native support');
994
1047
  if (!(NativeSTT as any)?.unPauseMicrophone) return Promise.resolve();
995
1048
  return new Promise((resolve, reject) => {
996
1049
  try { (NativeSTT as any).unPauseMicrophone(() => resolve()); }
@@ -1232,11 +1285,11 @@ class Speech {
1232
1285
 
1233
1286
  async playWav(pathOrURL: any, markAsLast = true) {
1234
1287
  // ✅ KEEP ALL YOUR EXISTING LOGGING + resolveAssetSource LOGIC
1235
- console.log('[Speech.playWav] called with:', pathOrURL, '| type:', typeof pathOrURL);
1288
+ dbg('[Speech.playWav] called with:', pathOrURL, '| type:', typeof pathOrURL);
1236
1289
  this.dbgAsset('playWav.arg', pathOrURL);
1237
1290
 
1238
1291
  const asset = resolveAssetSource(pathOrURL);
1239
- console.log('[Speech.playWav] resolveAssetSource ->', asset);
1292
+ dbg('[Speech.playWav] resolveAssetSource ->', asset);
1240
1293
 
1241
1294
  let realPath = asset?.uri ?? pathOrURL;
1242
1295
  if (Platform.OS === 'android' && typeof asset?.uri === 'string') {
@@ -1244,14 +1297,14 @@ class Speech {
1244
1297
  realPath = asset.uri;
1245
1298
  }
1246
1299
 
1247
- console.log('[Speech.playWav] resolved realPath:', realPath);
1300
+ dbg('[Speech.playWav] resolved realPath:', realPath);
1248
1301
 
1249
1302
  if (typeof realPath !== 'string') {
1250
1303
  realPath = String(realPath);
1251
- console.log('[Speech.playWav] converted ?? realPath:', realPath);
1304
+ dbg('[Speech.playWav] converted ?? realPath:', realPath);
1252
1305
  }
1253
1306
 
1254
- console.log('[Speech.playWav] before checking ios realPath:', realPath);
1307
+ dbg('[Speech.playWav] before checking ios realPath:', realPath);
1255
1308
 
1256
1309
  // ✅ IMPORTANT: separate logic per platform + queue only when markAsLast=true
1257
1310
  this.ensureListeners();
@@ -1267,15 +1320,15 @@ class Speech {
1267
1320
  return (NativeSpeech as any).playWav(realPath, false);
1268
1321
  }
1269
1322
 
1270
- console.log('[Speech.playWav] after checking ios realPath:', realPath);
1271
- console.log('[Speech.playWav] after checking ios realPath:', typeof realPath);
1323
+ dbg('[Speech.playWav] after checking ios realPath:', realPath);
1324
+ dbg('[Speech.playWav] after checking ios realPath:', typeof realPath);
1272
1325
 
1273
1326
  if (!NativeTTS?.playWav) {
1274
- console.log('[Speech.playWav] NativeTTS:', NativeTTS);
1275
- if (NativeTTS) console.log('[Speech.playWav] NativeTTS.playWav :', NativeTTS.playWav);
1327
+ dbg('[Speech.playWav] NativeTTS:', NativeTTS);
1328
+ if (NativeTTS) dbg('[Speech.playWav] NativeTTS.playWav :', NativeTTS.playWav);
1276
1329
  throw new Error('playWav not available on this platform.');
1277
1330
  }
1278
- console.log('[Speech.playWav] calling NativeTTS.playWav with type of realPath:', typeof realPath);
1331
+ dbg('[Speech.playWav] calling NativeTTS.playWav with type of realPath:', typeof realPath);
1279
1332
  return (NativeTTS as any).playWav(realPath, false);
1280
1333
  }
1281
1334
 
package/stt/index.ts CHANGED
@@ -1,6 +1,13 @@
1
1
  // stt/index.ts
2
2
  import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
3
3
 
4
+ const DEBUG_LOGS_ENABLED = false;
5
+ function debugLog(...args: any[]) {
6
+ if (!DEBUG_LOGS_ENABLED) return;
7
+ // eslint-disable-next-line no-console
8
+ console.log(...args);
9
+ }
10
+
4
11
  // Prefer new names; gracefully fall back to legacy names during migration.
5
12
  const STTNative =
6
13
  NativeModules.STT ||
@@ -9,7 +16,7 @@ const STTNative =
9
16
  NativeModules.RCTVoice;
10
17
 
11
18
  if (STTNative) {
12
- console.log('STTNative loaded:', Object.keys(STTNative));
19
+ debugLog('STTNative loaded:', Object.keys(STTNative));
13
20
  } else {
14
21
  console.error('STT native module is not linked correctly.');
15
22
  }
@@ -1,9 +1,15 @@
1
1
  import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
2
2
 
3
+ const DEBUG_LOGS_ENABLED = false;
4
+ function debugLog(...args) {
5
+ if (!DEBUG_LOGS_ENABLED) return;
6
+ console.log(...args);
7
+ }
8
+
3
9
  const { DaVoiceTTSBridge } = NativeModules;
4
10
 
5
11
  if (DaVoiceTTSBridge) {
6
- console.log('DaVoiceTTSBridge is loaded:', DaVoiceTTSBridge);
12
+ debugLog('DaVoiceTTSBridge is loaded:', DaVoiceTTSBridge);
7
13
  } else {
8
14
  console.error('DaVoiceTTSBridge is not linked correctly.');
9
15
  }