speech to text typo correction ()

Co-authored-by: Timothy Carambat <rambat1010@gmail.com>
This commit is contained in:
Yash Suresh Chandra 2025-02-27 04:56:08 +05:30 committed by GitHub
parent 6dd1fdc546
commit 23d5f368d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 8 deletions
.gitignore
frontend/src/components/WorkspaceChat/ChatContainer
PromptInput/SpeechToText
index.jsx

1
.gitignore vendored
View file

@ -9,3 +9,4 @@ v-env
aws_cf_deploy_anything_llm.json
yarn.lock
*.bak
.idea

View file

@ -36,7 +36,7 @@ export default function SpeechToText({ sendCommand }) {
});
}
function endTTSSession() {
function endSTTSession() {
SpeechRecognition.stopListening();
if (transcript.length > 0) {
sendCommand(transcript, true);
@ -50,18 +50,18 @@ export default function SpeechToText({ sendCommand }) {
(event) => {
if (event.ctrlKey && event.keyCode === 77) {
if (listening) {
endTTSSession();
endSTTSession();
} else {
startSTTSession();
}
}
},
[listening, endTTSSession, startSTTSession]
[listening, endSTTSession, startSTTSession]
);
function handlePromptUpdate(e) {
if (!e?.detail && timeout) {
endTTSSession();
endSTTSession();
clearTimeout(timeout);
}
}
@ -85,7 +85,7 @@ export default function SpeechToText({ sendCommand }) {
sendCommand(transcript, false);
clearTimeout(timeout);
timeout = setTimeout(() => {
endTTSSession();
endSTTSession();
}, SILENCE_INTERVAL);
}
}, [transcript, listening]);
@ -97,7 +97,7 @@ export default function SpeechToText({ sendCommand }) {
data-tooltip-id="tooltip-text-size-btn"
data-tooltip-content="Speak your prompt"
aria-label="Speak your prompt"
onClick={listening ? endTTSSession : startSTTSession}
onClick={listening ? endSTTSession : startSTTSession}
className={`border-none relative flex justify-center items-center opacity-60 hover:opacity-100 light:opacity-100 light:hover:opacity-60 cursor-pointer ${
!!listening ? "!opacity-100" : ""
}`}

View file

@ -68,14 +68,14 @@ export default function ChatContainer({ workspace, knownHistory = [] }) {
if (listening) {
// Stop the mic if the send button is clicked
endTTSSession();
endSTTSession();
}
setChatHistory(prevChatHistory);
setMessageEmit("");
setLoadingResponse(true);
};
function endTTSSession() {
function endSTTSession() {
SpeechRecognition.stopListening();
resetTranscript();
}