Open nhtoby311 opened 1 year ago
You can overcome this by using a continuous SpeechRecognition.startListening({ continuous: true });
and manage manually delay between last word received in transcript and stopListening.
Here an example that I use in my app:
` const DELAY_BEFORE_SEND_MESSAGE = 1500; const timeoutId = useRef<null | NodeJS.Timeout>(null);
useEffect(() => {
if (transcript) {
if (timeoutId.current) {
clearTimeout(timeoutId.current);
}
timeoutId.current = setTimeout(() => {
SpeechRecognition.stopListening();
// ACTION AFTER STOP LISTENING
}, DELAY_BEFORE_SEND_MESSAGE);
}
return () => {
if (timeoutId.current) {
clearTimeout(timeoutId.current);
}
};
}, [transcript]);
`
Since there is a delay between speaking and generating text transcript, I'm looking for a way to overcome this. I wonder if there is a way to get the time interval between the moment the user speak into the mic, and the time when the transcript is being generated?