mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2025-05-02 09:03:12 +00:00
speech to text typo correction (#3330)
Co-authored-by: Timothy Carambat <rambat1010@gmail.com>
This commit is contained in:
parent
6dd1fdc546
commit
23d5f368d9
3 changed files with 9 additions and 8 deletions
.gitignore
frontend/src/components/WorkspaceChat/ChatContainer
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,3 +9,4 @@ v-env
|
|||
aws_cf_deploy_anything_llm.json
|
||||
yarn.lock
|
||||
*.bak
|
||||
.idea
|
||||
|
|
|
@ -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" : ""
|
||||
}`}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue