fix: voice recording not stopping

This commit is contained in:
Timothy J. Baek 2024-09-21 04:27:18 +02:00
parent 426de76690
commit cb81dfe4ba

View File

@ -44,6 +44,7 @@
return `${minutes}:${formattedSeconds}`;
};
let stream;
let speechRecognition;
let mediaRecorder;
@ -159,7 +160,7 @@
const startRecording = async () => {
startDurationCounter();
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
stream = await navigator.mediaDevices.getUserMedia({ audio: true });
mediaRecorder = new MediaRecorder(stream);
mediaRecorder.onstart = () => {
console.log('Recording started');
@ -251,6 +252,13 @@
}
stopDurationCounter();
audioChunks = [];
if (stream) {
const tracks = stream.getTracks();
tracks.forEach((track) => track.stop());
}
stream = null;
};
const confirmRecording = async () => {