react-native-davoice-tts 1.0.368 → 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.
@@ -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.300" # Update to your package version
5
+ s.version = "1.0.302" # 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
- ccb550ff914e8c1d14ec4a143be82ebe tts-1.0.0.aar
1
+ c74f2a1a66110cce02e155b3fe2b7be1 tts-1.0.0.aar
@@ -1 +1 @@
1
- 9cdf4df23768ec8752362ea0cb4e47273d062fff tts-1.0.0.aar
1
+ 63f168215f50d203c886df6fe81f0183c525df84 tts-1.0.0.aar
@@ -654,8 +654,8 @@ RCT_EXPORT_METHOD(pauseSpeechRecognitionLiteAsync:(nonnull NSNumber *)timeoutMs
654
654
  {
655
655
  if (!self.stt) { resolve(@{@"ok": @(YES), @"reason": @""}); return; }
656
656
 
657
- NSNumber *t = timeoutMs ?: @(1500);
658
- if (t.doubleValue <= 0) t = @(1500);
657
+ NSNumber *t = timeoutMs ?: @(500);
658
+ if (t.doubleValue <= 0) t = @(500);
659
659
  CFTimeInterval startedAt = CACurrentMediaTime();
660
660
  SBDebugLog(@"[SpeechBridge] %@ pauseSpeechRecognitionLiteAsync begin timeoutMs=%@ stt=%@", SBNowString(), t, self.stt);
661
661
 
@@ -703,8 +703,8 @@ RCT_EXPORT_METHOD(unPauseSpeechRecognitionLiteAsync:(nonnull NSNumber *)times
703
703
  {
704
704
  if (!self.stt) { resolve(@{@"ok": @(YES), @"reason": @""}); return; }
705
705
 
706
- NSNumber *t = timeoutMs ?: @(2500);
707
- if (t.doubleValue <= 0) t = @(2500);
706
+ NSNumber *t = timeoutMs ?: @(500);
707
+ if (t.doubleValue <= 0) t = @(500);
708
708
  NSNumber *pf = preFetch ?: @(0);
709
709
  if (pf.doubleValue < 0) pf = @(0);
710
710
  CFTimeInterval startedAt = CACurrentMediaTime();
@@ -745,8 +745,8 @@ RCT_EXPORT_METHOD(pauseMicrophoneAsync:(nonnull NSNumber *)timeoutMs
745
745
  if (!self.stt) { resolve(@{@"ok": @(NO), @"reason": @"no_stt"}); return; }
746
746
 
747
747
  // Default if caller passes null/0
748
- NSNumber *t = timeoutMs ?: @(1500);
749
- if (t.doubleValue <= 0) t = @(1500);
748
+ NSNumber *t = timeoutMs ?: @(500);
749
+ if (t.doubleValue <= 0) t = @(500);
750
750
 
751
751
  // STT.swift will do the main-queue polling internally
752
752
  [self.stt pauseMicrophoneAndWait:t completion:^(BOOL ok, NSString * _Nullable reason) {
@@ -761,8 +761,8 @@ RCT_EXPORT_METHOD(unPauseMicrophoneAsync:(nonnull NSNumber *)timeoutMs
761
761
  {
762
762
  if (!self.stt) { resolve(@{@"ok": @(NO), @"reason": @"no_stt"}); return; }
763
763
 
764
- NSNumber *t = timeoutMs ?: @(2500);
765
- if (t.doubleValue <= 0) t = @(2500);
764
+ NSNumber *t = timeoutMs ?: @(500);
765
+ if (t.doubleValue <= 0) t = @(500);
766
766
 
767
767
  [self.stt unPauseMicrophoneAndWait:t completion:^(BOOL ok, NSString * _Nullable reason) {
768
768
  resolve(@{@"ok": @(ok), @"reason": reason ?: @""});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-davoice-tts",
3
- "version": "1.0.368",
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
@@ -21,6 +21,11 @@ function dbgErr(...args: any[]) {
21
21
  // eslint-disable-next-line no-console
22
22
  console.error(ts(), PFX, '❌', ...args);
23
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);
28
+ }
24
29
 
25
30
  function safeJson(x: any) {
26
31
  try {
@@ -50,7 +55,7 @@ function androidCallbackWithTimeout<T>(
50
55
  const timer = setTimeout(() => {
51
56
  if (settled) return;
52
57
  settled = true;
53
- dbgErr(`${label} timed out after ${timeoutMs}ms`);
58
+ dbgNotice(`IMPORTANT: ${label} reached timeout - please note this is not a bug`, { timeoutMs });
54
59
  resolve(undefined);
55
60
  }, timeoutMs);
56
61
  try {
@@ -831,12 +836,15 @@ class Speech {
831
836
  return this.start(locale);
832
837
  }
833
838
 
834
- // Android: native pauseSpeechRecognitionLite is now bounded internally (~1.5s, see
839
+ // Android: native pauseSpeechRecognitionLite is now bounded internally (~500ms, see
835
840
  // STT.kt runPauseResumeSerializedOnMain), so this timeout is a backstop, not the
836
841
  // primary fix - it guarantees this promise settles even if the bridge itself stalls.
837
- async pauseSpeechRecognition(timeoutMs: number = 2500): Promise<void> {
842
+ async pauseSpeechRecognition(timeoutMs: number = 500): Promise<void> {
838
843
  this.logCall('pauseSpeechRecognitionLite');
839
844
  const startedAt = Date.now();
845
+ const effectiveTimeoutMs = Number.isFinite(timeoutMs) && timeoutMs > 0
846
+ ? Math.min(timeoutMs, 500)
847
+ : 500;
840
848
 
841
849
  const mod: any = Platform.OS === 'ios' ? NativeSpeech : NativeSTT;
842
850
  const fn = mod?.pauseSpeechRecognitionLite;
@@ -848,17 +856,19 @@ class Speech {
848
856
  }
849
857
 
850
858
  if (Platform.OS === 'ios' && typeof mod?.pauseSpeechRecognitionLiteAsync === 'function') {
851
- dbg('[pauseSpeechRecognitionLiteAsync] begin', { ...(opId ? { opId } : {}), timeoutMs: 1500 });
852
- const result = await mod.pauseSpeechRecognitionLiteAsync(1500);
859
+ dbg('[pauseSpeechRecognitionLiteAsync] begin', { ...(opId ? { opId } : {}), timeoutMs: 500 });
860
+ const result = await mod.pauseSpeechRecognitionLiteAsync(500);
853
861
  dbg('[pauseSpeechRecognitionLiteAsync] resolved', { ...(opId ? { opId } : {}), elapsedMs: Date.now() - startedAt, result });
854
- 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
+ }
855
865
  return;
856
866
  }
857
867
  if (Platform.OS === 'ios') {
858
868
  await new Promise<void>((resolve, reject) => {
859
869
  try {
860
870
  fn.call(mod, (ok: boolean) => {
861
- if (!ok) dbgErr('pauseSpeechRecognitionLite returned false');
871
+ if (!ok) dbgNotice('IMPORTANT: pauseSpeechRecognitionLite reached timeout - please note this is not a bug');
862
872
  resolve();
863
873
  });
864
874
  } catch (e) {
@@ -870,14 +880,12 @@ class Speech {
870
880
 
871
881
  await androidCallbackWithTimeout<void>(
872
882
  (done) => {
873
- fn.call(mod, async (ok: boolean) => {
874
- if (!ok) dbgErr('pauseSpeechRecognitionLite returned false');
875
- // ✅ ANDROID: small delay before resolving
876
- if (Platform.OS === 'android') await sleep(500);
883
+ fn.call(mod, (ok: boolean) => {
884
+ if (!ok) dbgNotice('IMPORTANT: pauseSpeechRecognitionLite reached timeout - please note this is not a bug');
877
885
  done(undefined);
878
886
  });
879
887
  },
880
- timeoutMs,
888
+ effectiveTimeoutMs,
881
889
  'pauseSpeechRecognitionLite',
882
890
  );
883
891
  };
@@ -894,10 +902,13 @@ class Speech {
894
902
  async unPauseSpeechRecognition(
895
903
  times: number,
896
904
  preFetchMs: number = 0,
897
- timeoutMs: number = 2500,
905
+ timeoutMs: number = 500,
898
906
  ): Promise<void> {
899
907
  this.logCall('unPauseSpeechRecognitionLite', { times, preFetchMs });
900
908
  const startedAt = Date.now();
909
+ const effectiveTimeoutMs = Number.isFinite(timeoutMs) && timeoutMs > 0
910
+ ? Math.min(timeoutMs, 500)
911
+ : 500;
901
912
 
902
913
  const mod: any = Platform.OS === 'ios' ? NativeSpeech : NativeSTT;
903
914
  const fn = mod?.unPauseSpeechRecognitionLite;
@@ -909,8 +920,8 @@ class Speech {
909
920
  }
910
921
 
911
922
  if (Platform.OS === 'ios' && typeof mod?.unPauseSpeechRecognitionLiteAsync === 'function') {
912
- dbg('[unPauseSpeechRecognitionLiteAsync] begin', { ...(opId ? { opId } : {}), times, preFetchMs, timeoutMs });
913
- 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);
914
925
  dbg('[unPauseSpeechRecognitionLiteAsync] resolved', {
915
926
  ...(opId ? { opId } : {}),
916
927
  times,
@@ -918,7 +929,9 @@ class Speech {
918
929
  elapsedMs: Date.now() - startedAt,
919
930
  result,
920
931
  });
921
- 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
+ }
922
935
  return;
923
936
  }
924
937
 
@@ -926,7 +939,7 @@ class Speech {
926
939
  await new Promise<void>((resolve, reject) => {
927
940
  try {
928
941
  const done = (ok: boolean) => {
929
- if (!ok) dbgErr('unPauseSpeechRecognitionLite(times) returned false');
942
+ if (!ok) dbgNotice('IMPORTANT: unPauseSpeechRecognitionLite reached timeout - please note this is not a bug');
930
943
  dbg('[CALL unPauseSpeechRecognitionLite] native callback fired', { times, preFetchMs, ok });
931
944
  resolve();
932
945
  };
@@ -947,10 +960,8 @@ class Speech {
947
960
  }
948
961
  await androidCallbackWithTimeout<void>(
949
962
  (done) => {
950
- const nativeDone = async (ok: boolean) => {
951
- if (!ok) dbgErr('unPauseSpeechRecognitionLite(times) returned false');
952
- // ✅ ANDROID: small delay before resolving
953
- if (Platform.OS === 'android') await sleep(500);
963
+ const nativeDone = (ok: boolean) => {
964
+ if (!ok) dbgNotice('IMPORTANT: unPauseSpeechRecognitionLite reached timeout - please note this is not a bug');
954
965
  done(undefined);
955
966
  };
956
967
  if (Platform.OS === 'android' && preFetchMs > 0 && typeof mod?.unPauseSpeechRecognitionLiteWithPreFetch === 'function') {
@@ -959,7 +970,7 @@ class Speech {
959
970
  }
960
971
  fn.call(mod, times, nativeDone);
961
972
  },
962
- timeoutMs,
973
+ effectiveTimeoutMs,
963
974
  'unPauseSpeechRecognitionLite',
964
975
  );
965
976
  };
@@ -980,9 +991,11 @@ class Speech {
980
991
  if (Platform.OS === 'ios' && (NativeSpeech as any)?.pauseMicrophoneAsync) {
981
992
  dbg('IOS [pauseMicrophone] using NativeSpeech.pauseMicrophoneAsync()');
982
993
  try {
983
- const r = await (NativeSpeech as any).pauseMicrophoneAsync(1000);
994
+ const r = await (NativeSpeech as any).pauseMicrophoneAsync(500);
984
995
  dbg('pauseMicrophoneAsync result', r);
985
- 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
+ }
986
999
  return;
987
1000
  } catch (e) {
988
1001
  dbgErr('IOS [pauseMicrophone] NativeSpeech.pauseMicrophoneAsync() ERROR:', String(e));
@@ -1010,8 +1023,10 @@ class Speech {
1010
1023
  if (Platform.OS === 'ios' && (NativeSpeech as any)?.unPauseMicrophoneAsync) {
1011
1024
  dbg('IOS [unPauseMicrophone] using NativeSpeech.unPauseMicrophoneAsync()');
1012
1025
  try {
1013
- const r = await (NativeSpeech as any).unPauseMicrophoneAsync(1000);
1014
- 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
+ }
1015
1030
  dbg('IOS [unPauseMicrophone] NativeSpeech.unPauseMicrophoneAsync() DONE');
1016
1031
  return;
1017
1032
  } catch (e) {