react-native-davoice-tts 1.0.258 → 1.0.260
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.
- package/TTSRNBridge.podspec +1 -1
- package/ios/SpeechBridge/SpeechBridge.m +16 -0
- package/package.json +1 -1
- package/speech/index.ts +45 -2
package/TTSRNBridge.podspec
CHANGED
|
@@ -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.
|
|
5
|
+
s.version = "1.0.133" # 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 .
|
|
@@ -317,6 +317,22 @@ RCT_EXPORT_METHOD(initAll:(NSDictionary *)opts
|
|
|
317
317
|
});
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
+
// --- SpeechRecognitionLite pause/unpause (counter-based) ---
|
|
321
|
+
|
|
322
|
+
RCT_EXPORT_METHOD(pauseSpeechRecognitionLite:(RCTResponseSenderBlock)callback)
|
|
323
|
+
{
|
|
324
|
+
if (!self.stt) { if (callback) callback(@[@(NO)]); return; }
|
|
325
|
+
[self.stt pauseSpeechRecognitionLite];
|
|
326
|
+
if (callback) callback(@[@(YES)]);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
RCT_EXPORT_METHOD(unPauseSpeechRecognitionLite:(RCTResponseSenderBlock)callback)
|
|
330
|
+
{
|
|
331
|
+
if (!self.stt) { if (callback) callback(@[@(NO)]); return; }
|
|
332
|
+
[self.stt unPauseSpeechRecognitionLite];
|
|
333
|
+
if (callback) callback(@[@(YES)]);
|
|
334
|
+
}
|
|
335
|
+
|
|
320
336
|
// Promise-based pause that resolves ONLY when iOS is actually settled in playback (mic released)
|
|
321
337
|
RCT_EXPORT_METHOD(pauseMicrophoneAsync:(nonnull NSNumber *)timeoutMs
|
|
322
338
|
resolver:(RCTPromiseResolveBlock)resolve
|
package/package.json
CHANGED
package/speech/index.ts
CHANGED
|
@@ -131,7 +131,7 @@ class Speech {
|
|
|
131
131
|
return (NativeTTS as any).speak(text, speakerId, s);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
private _speakAndWait(text: string, speakerId: number, s: number, timeoutMs =
|
|
134
|
+
private _speakAndWait(text: string, speakerId: number, s: number, timeoutMs = 600000) {
|
|
135
135
|
return new Promise<void>((resolve, reject) => {
|
|
136
136
|
this.ttsPendingResolve = resolve;
|
|
137
137
|
// safety: never hang forever
|
|
@@ -409,6 +409,49 @@ class Speech {
|
|
|
409
409
|
});
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
+
// ---------- iOS-only: SpeechRecognitionLite pause/unpause ----------
|
|
413
|
+
pauseSpeechRecognition(): Promise<void> {
|
|
414
|
+
this.logCall('pauseSpeechRecognitionLite');
|
|
415
|
+
if (Platform.OS !== 'ios') return Promise.resolve();
|
|
416
|
+
|
|
417
|
+
if (!(NativeSpeech as any)?.pauseSpeechRecognitionLite) {
|
|
418
|
+
dbg('iOS pauseSpeechRecognitionLite not available on NativeSpeech');
|
|
419
|
+
return Promise.resolve();
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
return new Promise((resolve, reject) => {
|
|
423
|
+
try {
|
|
424
|
+
(NativeSpeech as any).pauseSpeechRecognitionLite((ok: boolean) => {
|
|
425
|
+
if (!ok) dbgErr('pauseSpeechRecognitionLite returned false');
|
|
426
|
+
resolve();
|
|
427
|
+
});
|
|
428
|
+
} catch (e) {
|
|
429
|
+
reject(e as any);
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
unPauseSpeechRecognition(): Promise<void> {
|
|
435
|
+
this.logCall('unPauseSpeechRecognitionLite');
|
|
436
|
+
if (Platform.OS !== 'ios') return Promise.resolve();
|
|
437
|
+
|
|
438
|
+
if (!(NativeSpeech as any)?.unPauseSpeechRecognitionLite) {
|
|
439
|
+
dbg('iOS unPauseSpeechRecognitionLite not available on NativeSpeech');
|
|
440
|
+
return Promise.resolve();
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
return new Promise((resolve, reject) => {
|
|
444
|
+
try {
|
|
445
|
+
(NativeSpeech as any).unPauseSpeechRecognitionLite((ok: boolean) => {
|
|
446
|
+
if (!ok) dbgErr('unPauseSpeechRecognitionLite returned false');
|
|
447
|
+
resolve();
|
|
448
|
+
});
|
|
449
|
+
} catch (e) {
|
|
450
|
+
reject(e as any);
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
|
|
412
455
|
/** Pause mic/STT (Android native; iOS unified if present) */
|
|
413
456
|
async pauseMicrophone(): Promise<void> {
|
|
414
457
|
console.log('[pauseMicrophone] called');
|
|
@@ -558,7 +601,7 @@ class Speech {
|
|
|
558
601
|
private wavChain: Promise<void> = Promise.resolve();
|
|
559
602
|
|
|
560
603
|
// ADD helper (minimal, uses existing onFinishedSpeaking event)
|
|
561
|
-
private _playWavAndWait(realPath: string, markAsLast: boolean, timeoutMs =
|
|
604
|
+
private _playWavAndWait(realPath: string, markAsLast: boolean, timeoutMs = 600000) {
|
|
562
605
|
return new Promise<void>((resolve, reject) => {
|
|
563
606
|
this.ttsPendingResolve = resolve; // reuse existing resolver + event
|
|
564
607
|
this.ttsPendingTimeout = setTimeout(() => {
|