mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-06-15 23:43:06 +03:00
Update SpeechRecognition.tsx
This commit is contained in:
@@ -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 };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user