mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +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 { useState, useEffect } from 'react';
|
||||||
|
import hotkeys from 'hotkeys-js';
|
||||||
|
|
||||||
const useSpeechRecognition = (ask) => {
|
const useSpeechRecognition = (ask) => {
|
||||||
const [isSpeechSupported, setIsSpeechSupported] = useState(false);
|
const [isSpeechSupported, setIsSpeechSupported] = useState(false);
|
||||||
|
|
@ -66,21 +67,17 @@ const useSpeechRecognition = (ask) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleKeyDown = (e) => {
|
useEffect(() => {
|
||||||
if (e.shiftKey && e.altKey && e.key === 'L') {
|
hotkeys('shift+alt+l', (event, handler) => {
|
||||||
if (isSpeechSupported) {
|
if (isSpeechSupported) {
|
||||||
toggleListening();
|
toggleListening();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
window.addEventListener('keydown', handleKeyDown);
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener('keydown', handleKeyDown);
|
hotkeys.unbind('shift+alt+l');
|
||||||
};
|
};
|
||||||
});
|
}, [isSpeechSupported]);
|
||||||
|
|
||||||
return { isSpeechSupported, isListening, text, toggleListening };
|
return { isSpeechSupported, isListening, text, toggleListening };
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue