From 4d6132b9de4abf3d0ba59728e9562176a0193e81 Mon Sep 17 00:00:00 2001 From: vincent-thevenin Date: Mon, 3 Mar 2025 13:59:28 +0100 Subject: [PATCH] fix: fix issue with call voice recording starting before voice detection --- src/lib/components/chat/MessageInput/CallOverlay.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/components/chat/MessageInput/CallOverlay.svelte b/src/lib/components/chat/MessageInput/CallOverlay.svelte index c7a2d4d1e..c993681c5 100644 --- a/src/lib/components/chat/MessageInput/CallOverlay.svelte +++ b/src/lib/components/chat/MessageInput/CallOverlay.svelte @@ -231,7 +231,6 @@ mediaRecorder.onstart = () => { console.log('Recording started'); audioChunks = []; - analyseAudio(audioStream); }; mediaRecorder.ondataavailable = (event) => { @@ -245,7 +244,7 @@ stopRecordingCallback(); }; - mediaRecorder.start(); + analyseAudio(audioStream); } }; @@ -321,6 +320,9 @@ if (hasSound) { // BIG RED TEXT console.log('%c%s', 'color: red; font-size: 20px;', '🔊 Sound detected'); + if (mediaRecorder && mediaRecorder.state !== 'recording') { + mediaRecorder.start(); + } if (!hasStartedSpeaking) { hasStartedSpeaking = true;