mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
Update SpeechSynthesis.tsx
This commit is contained in:
parent
4c6d067cb9
commit
39e84efa81
1 changed files with 0 additions and 33 deletions
|
|
@ -1,50 +1,17 @@
|
||||||
//import { useState, useEffect } from 'react';
|
|
||||||
|
|
||||||
function useSpeechSynthesis() {
|
function useSpeechSynthesis() {
|
||||||
//const [isSpeechEnabled, setIsSpeechEnabled] = useState(false);
|
|
||||||
//const [textToSpeak, setTextToSpeak] = useState('');
|
|
||||||
|
|
||||||
const synthesizeSpeech = (text) => {
|
const synthesizeSpeech = (text) => {
|
||||||
const synth = window.speechSynthesis;
|
const synth = window.speechSynthesis;
|
||||||
synth.cancel();
|
synth.cancel();
|
||||||
const utterance = new SpeechSynthesisUtterance(text);
|
const utterance = new SpeechSynthesisUtterance(text);
|
||||||
synth.speak(utterance);
|
synth.speak(utterance);
|
||||||
//setTextToSpeak(text);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//const toggleSpeechSynthesis = () => {
|
|
||||||
// setIsSpeechEnabled(!isSpeechEnabled);
|
|
||||||
// console.log('Toggle Text-To-Speech', !isSpeechEnabled);
|
|
||||||
//};
|
|
||||||
|
|
||||||
const cancelSpeech = () => {
|
const cancelSpeech = () => {
|
||||||
const synth = window.speechSynthesis;
|
const synth = window.speechSynthesis;
|
||||||
synth.cancel();
|
synth.cancel();
|
||||||
};
|
};
|
||||||
|
|
||||||
//const handleKeyDown = (event) => {
|
|
||||||
// if (event.shiftKey && event.altKey && event.key === 'P') {
|
|
||||||
// toggleSpeechSynthesis();
|
|
||||||
// }
|
|
||||||
//};
|
|
||||||
|
|
||||||
//useEffect(() => {
|
|
||||||
// window.addEventListener('keydown', handleKeyDown);
|
|
||||||
|
|
||||||
// return () => {
|
|
||||||
// window.removeEventListener('keydown', handleKeyDown);
|
|
||||||
// };
|
|
||||||
// }, [isSpeechEnabled]);
|
|
||||||
|
|
||||||
//useEffect(() => {
|
|
||||||
// if (!isSpeechEnabled || !textToSpeak) return;
|
|
||||||
|
|
||||||
// const synth = window.speechSynthesis;
|
|
||||||
// synth.cancel();
|
|
||||||
// const utterance = new SpeechSynthesisUtterance(textToSpeak);
|
|
||||||
// synth.speak(utterance);
|
|
||||||
//}, [textToSpeak, isSpeechEnabled]);
|
|
||||||
// return { synthesizeSpeech, toggleSpeechSynthesis, cancelSpeech, isSpeechEnabled };
|
|
||||||
return { synthesizeSpeech, cancelSpeech };
|
return { synthesizeSpeech, cancelSpeech };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue