mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
Update SpeechRecognition.tsx
This commit is contained in:
parent
5b80ddfba7
commit
6686126dc0
1 changed files with 6 additions and 9 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { useState, useEffect } from 'react';
|
||||
import hotkeys from 'hotkeys-js';
|
||||
|
||||
const useSpeechRecognition = (ask) => {
|
||||
const [isSpeechSupported, setIsSpeechSupported] = useState(false);
|
||||
|
|
@ -66,21 +67,17 @@ const useSpeechRecognition = (ask) => {
|
|||
}
|
||||
};
|
||||
|
||||
const handleKeyDown = (e) => {
|
||||
if (e.shiftKey && e.altKey && e.key === 'L') {
|
||||
useEffect(() => {
|
||||
hotkeys('shift+alt+l', (event, handler) => {
|
||||
if (isSpeechSupported) {
|
||||
toggleListening();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener('keydown', handleKeyDown);
|
||||
});
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('keydown', handleKeyDown);
|
||||
hotkeys.unbind('shift+alt+l');
|
||||
};
|
||||
});
|
||||
}, [isSpeechSupported]);
|
||||
|
||||
return { isSpeechSupported, isListening, text, toggleListening };
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue