@contentgrowth/llm-service 0.9.6 → 0.9.8
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.
|
@@ -217,12 +217,13 @@ var useSpeechRecognition = (onResult, onEnd, language = "en-US") => {
|
|
|
217
217
|
const recognition = new SpeechRecognition();
|
|
218
218
|
recognition.continuous = true;
|
|
219
219
|
recognition.interimResults = true;
|
|
220
|
-
recognition.lang = language;
|
|
221
220
|
recognition.onstart = () => {
|
|
221
|
+
console.log("[useSpeechRecognition] Native onstart event fired");
|
|
222
222
|
setIsListening(true);
|
|
223
223
|
setError(null);
|
|
224
224
|
};
|
|
225
225
|
recognition.onend = () => {
|
|
226
|
+
console.log("[useSpeechRecognition] Native onend event fired");
|
|
226
227
|
if (isSimulatingRef.current) {
|
|
227
228
|
return;
|
|
228
229
|
}
|
|
@@ -270,6 +271,7 @@ var useSpeechRecognition = (onResult, onEnd, language = "en-US") => {
|
|
|
270
271
|
}
|
|
271
272
|
}
|
|
272
273
|
return () => {
|
|
274
|
+
console.log("[useSpeechRecognition] Effect cleanup - stopping recognition");
|
|
273
275
|
if (isSimulatingRef.current && simulationTimeoutRef.current) {
|
|
274
276
|
clearTimeout(simulationTimeoutRef.current);
|
|
275
277
|
simulationTimeoutRef.current = null;
|
|
@@ -278,19 +280,30 @@ var useSpeechRecognition = (onResult, onEnd, language = "en-US") => {
|
|
|
278
280
|
recognitionRef.current.stop();
|
|
279
281
|
}
|
|
280
282
|
};
|
|
283
|
+
}, []);
|
|
284
|
+
(0, import_react2.useEffect)(() => {
|
|
285
|
+
if (recognitionRef.current) {
|
|
286
|
+
console.log("[useSpeechRecognition] Updating language to:", language);
|
|
287
|
+
recognitionRef.current.lang = language;
|
|
288
|
+
}
|
|
281
289
|
}, [language]);
|
|
282
290
|
const start = (0, import_react2.useCallback)(() => {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
console.error("[useSpeechRecognition] Failed to start speech recognition:", e);
|
|
289
|
-
}
|
|
290
|
-
} else {
|
|
291
|
+
console.log("[useSpeechRecognition] start() called");
|
|
292
|
+
if (isSimulatingRef.current) return;
|
|
293
|
+
if (!recognitionRef.current) {
|
|
294
|
+
console.error("[useSpeechRecognition] Recognition instance missing");
|
|
295
|
+
return;
|
|
291
296
|
}
|
|
292
|
-
|
|
297
|
+
try {
|
|
298
|
+
setTranscript("");
|
|
299
|
+
recognitionRef.current.start();
|
|
300
|
+
console.log("[useSpeechRecognition] recognition.start() executed");
|
|
301
|
+
} catch (error2) {
|
|
302
|
+
console.error("[useSpeechRecognition] Failed to start recognition:", error2);
|
|
303
|
+
}
|
|
304
|
+
}, []);
|
|
293
305
|
const stop = (0, import_react2.useCallback)(() => {
|
|
306
|
+
console.log("[useSpeechRecognition] stop() called");
|
|
294
307
|
if (isSimulatingRef.current) {
|
|
295
308
|
if (simulationTimeoutRef.current) {
|
|
296
309
|
clearTimeout(simulationTimeoutRef.current);
|
|
@@ -304,11 +317,11 @@ var useSpeechRecognition = (onResult, onEnd, language = "en-US") => {
|
|
|
304
317
|
if (onEndRef.current) onEndRef.current();
|
|
305
318
|
return;
|
|
306
319
|
}
|
|
307
|
-
if (recognitionRef.current
|
|
320
|
+
if (recognitionRef.current) {
|
|
308
321
|
recognitionRef.current.stop();
|
|
309
|
-
|
|
322
|
+
console.log("[useSpeechRecognition] recognition.stop() executed");
|
|
310
323
|
}
|
|
311
|
-
}, [
|
|
324
|
+
}, []);
|
|
312
325
|
const resetTranscript = (0, import_react2.useCallback)(() => {
|
|
313
326
|
setTranscript("");
|
|
314
327
|
}, []);
|
|
@@ -918,6 +931,7 @@ var TapToTalk = ({
|
|
|
918
931
|
const isListening = !!voiceTrigger || nativeSpeech.isListening || customRecorder.isRecording;
|
|
919
932
|
const isActive = isListening || isTranscribing;
|
|
920
933
|
const toggleVoice = async () => {
|
|
934
|
+
console.log("[TapToTalk] toggleVoice called. isActive:", isActive);
|
|
921
935
|
const now = Date.now();
|
|
922
936
|
if (now - tapCountRef.current.lastTap < 500) {
|
|
923
937
|
tapCountRef.current.count++;
|
|
@@ -929,6 +943,7 @@ var TapToTalk = ({
|
|
|
929
943
|
setShowDebug((prev) => !prev);
|
|
930
944
|
tapCountRef.current.count = 0;
|
|
931
945
|
if (isActive) {
|
|
946
|
+
console.log("[TapToTalk] Debug trigger force-stop");
|
|
932
947
|
if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "native") nativeSpeech.stop();
|
|
933
948
|
else customRecorder.stop();
|
|
934
949
|
setVoiceTrigger(null);
|
|
@@ -936,7 +951,11 @@ var TapToTalk = ({
|
|
|
936
951
|
return;
|
|
937
952
|
}
|
|
938
953
|
if (isActive) {
|
|
939
|
-
if (isTranscribing && !isListening)
|
|
954
|
+
if (isTranscribing && !isListening) {
|
|
955
|
+
console.log("[TapToTalk] Ignoring click during transcription");
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
console.log("[TapToTalk] Stopping voice...");
|
|
940
959
|
if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "native") {
|
|
941
960
|
nativeSpeech.stop();
|
|
942
961
|
} else {
|
|
@@ -944,6 +963,7 @@ var TapToTalk = ({
|
|
|
944
963
|
}
|
|
945
964
|
setVoiceTrigger(null);
|
|
946
965
|
} else {
|
|
966
|
+
console.log("[TapToTalk] Starting voice...");
|
|
947
967
|
setErrorMsg(null);
|
|
948
968
|
onFocusTarget == null ? void 0 : onFocusTarget();
|
|
949
969
|
setVoiceTrigger("click");
|