From 79754772b49e3b3133585a11abbe3783aa194998 Mon Sep 17 00:00:00 2001 From: Prince Baghel Date: Mon, 23 Sep 2024 17:23:45 +0530 Subject: [PATCH] update: queue handling user input as well --- src/components/inputBar.tsx | 11 ++++++++++- src/components/inputBar2.tsx | 12 +++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/components/inputBar.tsx b/src/components/inputBar.tsx index a88580f..fef3904 100644 --- a/src/components/inputBar.tsx +++ b/src/components/inputBar.tsx @@ -371,7 +371,9 @@ const InputBar = (props: InputBarProps) => { }; useEffect(() => { - props?.setInput?.(Object.values(transcriptHashTable).join(" ")); + if (Object.keys(transcriptHashTable).length > 0) { + props?.setInput?.(Object.values(transcriptHashTable).join(" ")); + } }, [transcriptHashTable]); useEffect(() => { if ( @@ -600,9 +602,16 @@ const InputBar = (props: InputBarProps) => { onStartListening={() => { setIsBlinking(true); setIsAudioWaveVisible(true); + const newAudioId = audioId + 1; + setAudioId(newAudioId); + setTranscriptHashTable((prev) => ({ + ...prev, + [newAudioId]: props.value, + })); }} onStopListening={() => { setIsBlinking(false); + setTranscriptHashTable({}); setIsAudioWaveVisible(false); }} // disabled={isRecording || isTranscribing || disableInputs} diff --git a/src/components/inputBar2.tsx b/src/components/inputBar2.tsx index dbe9d29..4cc56ac 100644 --- a/src/components/inputBar2.tsx +++ b/src/components/inputBar2.tsx @@ -360,7 +360,9 @@ const InputBar = (props: InputBarProps) => { }; useEffect(() => { - props?.setInput?.(Object.values(transcriptHashTable).join(" ")); + if (Object.keys(transcriptHashTable).length > 0) { + props?.setInput?.(Object.values(transcriptHashTable).join(" ")); + } }, [transcriptHashTable]); //TODO: @@ -457,9 +459,17 @@ const InputBar = (props: InputBarProps) => { onStartListening={() => { setIsBlinking(true); setIsAudioWaveVisible(true); + const newAudioId = audioId + 1; + setAudioId(newAudioId); + setTranscriptHashTable((prev) => ({ + ...prev, + [newAudioId]: props?.value || "", + })); + setIsAudioWaveVisible(true); }} onStopListening={() => { setIsBlinking(false); + setTranscriptHashTable({}); setIsAudioWaveVisible(false); }} // disabled={isRecording || isTranscribing || disableInputs}