speech to text typo correction (#3330)

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
3 changed files with 9 additions and 8 deletions

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();
}