Skip to content

Commit

Permalink
whisper uses generating lock + stop generating button has onClick rat…
Browse files Browse the repository at this point in the history
…her than whole div fixes #87
  • Loading branch information
jackschedel committed Jan 6, 2024
1 parent a8504ca commit ca21a2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/components/Chat/ChatContent/Message/WhisperRecord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ const WhisperRecord = ({
messageIndex: number;
}) => {
let apiKey = useStore((state) => state.apiKey);

const setGenerating = useStore((state) => state.setGenerating);
apiKey = apiKey || '0';

const { transcript, startRecording, stopRecording } = useWhisper({ apiKey });

useEffect(() => {
if (transcript.text) {
if (transcript.text != null) {
_setContent((prev) => {
return prev.replace('◯', transcript.text || '');
});
setGenerating(false);
}
}, [transcript.text]);

Expand Down Expand Up @@ -54,6 +55,7 @@ const WhisperRecord = ({
return startContent + paddedStart + '◉' + paddedEnd + endContent;
});
startRecording();
setGenerating(true);
}
setIsRecording(!isRecording);
};
Expand Down
6 changes: 2 additions & 4 deletions src/components/StopGeneratingButton/StopGeneratingButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ const StopGeneratingButton = () => {
const generating = useStore((state) => state.generating);

return generating ? (
<div
className='absolute bottom-6 left-0 right-0 m-auto flex md:w-full md:m-auto gap-0 md:gap-2 justify-center'
onClick={() => setGenerating(false)}
>
<div className='absolute bottom-6 left-0 right-0 m-auto flex md:w-full md:m-auto gap-0 md:gap-2 justify-center'>
<button
className='btn relative btn-neutral border-0 md:border hover:bg-neutral-dark'
aria-label='stop generating'
onClick={() => setGenerating(false)}
>
<div className='flex w-full items-center justify-center gap-2'>
<svg
Expand Down

0 comments on commit ca21a2d

Please sign in to comment.