From eb842c699b9dde3d21dc69cc72fb7812be8d4f5c Mon Sep 17 00:00:00 2001 From: bsu3338 Date: Sat, 5 Aug 2023 09:42:49 -0500 Subject: [PATCH] Update TextChat.jsx --- client/src/components/Input/TextChat.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/components/Input/TextChat.jsx b/client/src/components/Input/TextChat.jsx index f80e94c558..64cab7094e 100644 --- a/client/src/components/Input/TextChat.jsx +++ b/client/src/components/Input/TextChat.jsx @@ -29,7 +29,7 @@ export default function TextChat({ isSearchView = false }) { const { ask, stopGenerating } = useMessageHandler(); const isNotAppendable = latestMessage?.unfinished & !isSubmitting || latestMessage?.error; const { conversationId, jailbreak } = conversation || {}; - + const { isSpeechSupported, isListening, text: speechText, toggleListening } = useSpeechRecognition(); // auto focus to input, when enter a conversation. useEffect(() => { @@ -60,6 +60,9 @@ export default function TextChat({ isSearchView = false }) { const submitMessage = () => { ask({ text }); setText(''); + if (isListening) { + toggleListening(); + } }; const handleStopGenerating = (e) => { @@ -81,7 +84,7 @@ export default function TextChat({ isSearchView = false }) { } if (e.shiftKey && e.altKey && e.key === 'L') { - toggleListening(e); + toggleListening(); } }; @@ -111,7 +114,7 @@ export default function TextChat({ isSearchView = false }) { const changeHandler = (e) => { const { value } = e.target; - setText(value); + setText(value || speechText); }; const getPlaceholderText = () => {