Created
July 29, 2021 21:21
-
-
Save lmcarreiro/3a9426a934554c2388cfcba3ef8b41fc to your computer and use it in GitHub Desktop.
STT+VAD article - useSpeechToText.diff - 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Control the streaming flag, based on the voice activity detection (that uses hark) and the mute/unmute flag | |
React.useEffect(() => { | |
if (shouldStream) { | |
console.log("Voice activity detected, starting streaming current buffer + live streaming..."); | |
streamingFlagRef.current = true; | |
} else { | |
console.log("No voice activity detected, stopped streaming."); | |
+ const timeout = setTimeout(() => { | |
streamingFlagRef.current = false; | |
+ }, 2_000); | |
+ | |
+ return () => clearTimeout(timeout); | |
} | |
}, [shouldStream]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment