react-native-davoice-tts 1.0.223 → 1.0.224

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.96" # Update to your package version
5
+ s.version = "1.0.97" # 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
- b6f649e4214247f6227a360f42a39d24 tts-1.0.0.aar
1
+ 42c267a5b4662b699c6c308fcfc2fba6 tts-1.0.0.aar
@@ -1 +1 @@
1
- cb0eb9b0e301262eeee35378d269f5716fcfe679 tts-1.0.0.aar
1
+ 8f051f8e1bd46e4272db8ee5f2081f6115fa6dd6 tts-1.0.0.aar
@@ -86,6 +86,13 @@ class STTModule(private val rc: ReactApplicationContext)
86
86
  cb.invoke(false)
87
87
  }
88
88
 
89
+ /** Start MIC+VAD remote capture that emits a single WAV via onNewSpeechWAV */
90
+ @ReactMethod
91
+ fun startRemoteSpeech(cb: Callback) {
92
+ ensure().startRemoteSpeech()
93
+ cb.invoke(false)
94
+ }
95
+
89
96
  // ===== Events -> JS =====
90
97
 
91
98
  override fun onSpeechStart() {
@@ -127,4 +134,11 @@ class STTModule(private val rc: ReactApplicationContext)
127
134
  val m = Arguments.createMap().apply { putDouble("value", value.toDouble()) }
128
135
  send("onSpeechVolumeChanged", m)
129
136
  }
137
+
138
+ /** Forward the saved WAV file path to JS */
139
+ override fun onNewSpeechWAV(filePath: String) {
140
+ val m = Arguments.createMap().apply { putString("path", filePath) }
141
+ send("onNewSpeechWAV", m)
142
+ }
143
+
130
144
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-davoice-tts",
3
- "version": "1.0.223",
3
+ "version": "1.0.224",
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
@@ -28,6 +28,7 @@ export type SpeechRecognizedEvent = { isFinal: boolean };
28
28
  export type SpeechErrorEvent = { error: { code?: string; message?: string } };
29
29
  export type SpeechResultsEvent = { value: string[] };
30
30
  export type SpeechVolumeChangeEvent = { value: number };
31
+ export type NewSpeechWAVEvent = { path: string };
31
32
 
32
33
  export type UnifiedEvents = {
33
34
  // STT
@@ -38,6 +39,8 @@ export type UnifiedEvents = {
38
39
  onSpeechResults?: (e: SpeechResultsEvent) => void;
39
40
  onSpeechPartialResults?: (e: SpeechResultsEvent) => void;
40
41
  onSpeechVolumeChanged?: (e: SpeechVolumeChangeEvent) => void;
42
+ /** Android-only: emitted when native MIC+VAD saves a full utterance WAV */
43
+ onNewSpeechWAV?: (e: NewSpeechWAVEvent) => void;
41
44
  // TTS
42
45
  onFinishedSpeaking?: () => void;
43
46
  };
@@ -50,6 +53,7 @@ type NativeEventName =
50
53
  | 'onSpeechResults'
51
54
  | 'onSpeechPartialResults'
52
55
  | 'onSpeechVolumeChanged'
56
+ | 'onNewSpeechWAV'
53
57
  | 'onFinishedSpeaking';
54
58
 
55
59
  // --- NEW: descriptor for external PCM payloads ---
@@ -88,6 +92,7 @@ class Speech {
88
92
  onSpeechResults: () => {},
89
93
  onSpeechPartialResults: () => {},
90
94
  onSpeechVolumeChanged: () => {},
95
+ onNewSpeechWAV: () => {},
91
96
  onFinishedSpeaking: () => {},
92
97
  };
93
98
 
@@ -125,6 +130,30 @@ private rewireListenersForMode() {
125
130
  this.ensureListeners();
126
131
  }
127
132
 
133
+ // ---------- Init / Destroy ----------
134
+ /**
135
+ * ANDROID ONLY: Initialize remote capture (MIC + VAD) that saves utterances to WAV
136
+ * and emits 'onNewSpeechWAV' with { path }. No-op on iOS (throws).
137
+ */
138
+ async initAllRemoteSTT(): Promise<void> {
139
+ if (Platform.OS !== 'android') {
140
+ throw new Error('initAllRemoteSTT is Android-only.');
141
+ }
142
+ if (!NativeSTT?.startRemoteSpeech) {
143
+ throw new Error('Native STT module missing startRemoteSpeech()');
144
+ }
145
+ this.ensureListeners();
146
+ await new Promise<void>((resolve, reject) => {
147
+ try {
148
+ NativeSTT.startRemoteSpeech((err: string) => (err ? reject(new Error(err)) : resolve()));
149
+ } catch (e) {
150
+ reject(e as any);
151
+ }
152
+ });
153
+ }
154
+
155
+
156
+
128
157
  // ---------- Init / Destroy ----------
129
158
  /**
130
159
  * iOS: initialize STT then TTS via native SpeechBridge if available.
@@ -481,6 +510,7 @@ private rewireListenersForMode() {
481
510
  onSpeechResults: (e: any) => this.handlers.onSpeechResults(e),
482
511
  onSpeechPartialResults: (e: any) => this.handlers.onSpeechPartialResults(e),
483
512
  onSpeechVolumeChanged: (e: any) => this.handlers.onSpeechVolumeChanged(e),
513
+ onNewSpeechWAV: (e: any) => this.handlers.onNewSpeechWAV(e),
484
514
  };
485
515
  (Object.keys(sttMap) as (keyof typeof sttMap)[]).forEach((name) => {
486
516
  try {
@@ -512,6 +542,7 @@ private rewireListenersForMode() {
512
542
  set onSpeechResults(fn: (e: SpeechResultsEvent) => void) { this.handlers.onSpeechResults = fn; this.ensureListeners(); }
513
543
  set onSpeechPartialResults(fn: (e: SpeechResultsEvent) => void) { this.handlers.onSpeechPartialResults = fn; this.ensureListeners(); }
514
544
  set onSpeechVolumeChanged(fn: (e: SpeechVolumeChangeEvent) => void) { this.handlers.onSpeechVolumeChanged = fn; this.ensureListeners(); }
545
+ set onNewSpeechWAV(fn: (e: NewSpeechWAVEvent) => void) { this.handlers.onNewSpeechWAV = fn; this.ensureListeners(); }
515
546
  set onFinishedSpeaking(fn: () => void) { this.handlers.onFinishedSpeaking = fn; this.ensureListeners(); }
516
547
  }
517
548