Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion app/components/chat/BaseChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Workbench } from '~/components/workbench/Workbench.client';
import { classNames } from '~/utils/classNames';
import { Messages } from './Messages.client';
import { SendButton } from './SendButton.client';
import SpeechRecognition, { useSpeechRecognition } from 'react-speech-recognition'; // Import SpeechRecognition

import styles from './BaseChat.module.scss';

Expand Down Expand Up @@ -59,6 +60,17 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
) => {
const TEXTAREA_MAX_HEIGHT = chatStarted ? 400 : 200;

// SpeechRecognition hooks
const { transcript, listening, resetTranscript } = useSpeechRecognition();

const handleStartListening = () => {
SpeechRecognition.startListening({ continuous: true, language: 'en-US' });
};

const handleStopListening = () => {
SpeechRecognition.stopListening();
};

return (
<div
ref={ref}
Expand Down Expand Up @@ -122,7 +134,7 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
sendMessage?.(event);
}
}}
value={input}
value={input || transcript}
onChange={(event) => {
handleInputChange?.(event);
}}
Expand Down
Loading
Loading