@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.
@@ -175,12 +175,13 @@ var useSpeechRecognition = (onResult, onEnd, language = "en-US") => {
175
175
  const recognition = new SpeechRecognition();
176
176
  recognition.continuous = true;
177
177
  recognition.interimResults = true;
178
- recognition.lang = language;
179
178
  recognition.onstart = () => {
179
+ console.log("[useSpeechRecognition] Native onstart event fired");
180
180
  setIsListening(true);
181
181
  setError(null);
182
182
  };
183
183
  recognition.onend = () => {
184
+ console.log("[useSpeechRecognition] Native onend event fired");
184
185
  if (isSimulatingRef.current) {
185
186
  return;
186
187
  }
@@ -228,6 +229,7 @@ var useSpeechRecognition = (onResult, onEnd, language = "en-US") => {
228
229
  }
229
230
  }
230
231
  return () => {
232
+ console.log("[useSpeechRecognition] Effect cleanup - stopping recognition");
231
233
  if (isSimulatingRef.current && simulationTimeoutRef.current) {
232
234
  clearTimeout(simulationTimeoutRef.current);
233
235
  simulationTimeoutRef.current = null;
@@ -236,19 +238,30 @@ var useSpeechRecognition = (onResult, onEnd, language = "en-US") => {
236
238
  recognitionRef.current.stop();
237
239
  }
238
240
  };
241
+ }, []);
242
+ useEffect(() => {
243
+ if (recognitionRef.current) {
244
+ console.log("[useSpeechRecognition] Updating language to:", language);
245
+ recognitionRef.current.lang = language;
246
+ }
239
247
  }, [language]);
240
248
  const start = useCallback(() => {
241
- if (recognitionRef.current && !isListening) {
242
- try {
243
- setTranscript("");
244
- recognitionRef.current.start();
245
- } catch (e) {
246
- console.error("[useSpeechRecognition] Failed to start speech recognition:", e);
247
- }
248
- } else {
249
+ console.log("[useSpeechRecognition] start() called");
250
+ if (isSimulatingRef.current) return;
251
+ if (!recognitionRef.current) {
252
+ console.error("[useSpeechRecognition] Recognition instance missing");
253
+ return;
249
254
  }
250
- }, [isListening]);
255
+ try {
256
+ setTranscript("");
257
+ recognitionRef.current.start();
258
+ console.log("[useSpeechRecognition] recognition.start() executed");
259
+ } catch (error2) {
260
+ console.error("[useSpeechRecognition] Failed to start recognition:", error2);
261
+ }
262
+ }, []);
251
263
  const stop = useCallback(() => {
264
+ console.log("[useSpeechRecognition] stop() called");
252
265
  if (isSimulatingRef.current) {
253
266
  if (simulationTimeoutRef.current) {
254
267
  clearTimeout(simulationTimeoutRef.current);
@@ -262,11 +275,11 @@ var useSpeechRecognition = (onResult, onEnd, language = "en-US") => {
262
275
  if (onEndRef.current) onEndRef.current();
263
276
  return;
264
277
  }
265
- if (recognitionRef.current && isListening) {
278
+ if (recognitionRef.current) {
266
279
  recognitionRef.current.stop();
267
- } else {
280
+ console.log("[useSpeechRecognition] recognition.stop() executed");
268
281
  }
269
- }, [isListening, onResult, onEnd]);
282
+ }, []);
270
283
  const resetTranscript = useCallback(() => {
271
284
  setTranscript("");
272
285
  }, []);
@@ -876,6 +889,7 @@ var TapToTalk = ({
876
889
  const isListening = !!voiceTrigger || nativeSpeech.isListening || customRecorder.isRecording;
877
890
  const isActive = isListening || isTranscribing;
878
891
  const toggleVoice = async () => {
892
+ console.log("[TapToTalk] toggleVoice called. isActive:", isActive);
879
893
  const now = Date.now();
880
894
  if (now - tapCountRef.current.lastTap < 500) {
881
895
  tapCountRef.current.count++;
@@ -887,6 +901,7 @@ var TapToTalk = ({
887
901
  setShowDebug((prev) => !prev);
888
902
  tapCountRef.current.count = 0;
889
903
  if (isActive) {
904
+ console.log("[TapToTalk] Debug trigger force-stop");
890
905
  if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "native") nativeSpeech.stop();
891
906
  else customRecorder.stop();
892
907
  setVoiceTrigger(null);
@@ -894,7 +909,11 @@ var TapToTalk = ({
894
909
  return;
895
910
  }
896
911
  if (isActive) {
897
- if (isTranscribing && !isListening) return;
912
+ if (isTranscribing && !isListening) {
913
+ console.log("[TapToTalk] Ignoring click during transcription");
914
+ return;
915
+ }
916
+ console.log("[TapToTalk] Stopping voice...");
898
917
  if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "native") {
899
918
  nativeSpeech.stop();
900
919
  } else {
@@ -902,6 +921,7 @@ var TapToTalk = ({
902
921
  }
903
922
  setVoiceTrigger(null);
904
923
  } else {
924
+ console.log("[TapToTalk] Starting voice...");
905
925
  setErrorMsg(null);
906
926
  onFocusTarget == null ? void 0 : onFocusTarget();
907
927
  setVoiceTrigger("click");