mirror of
https://github.com/open-webui/open-webui
synced 2024-11-17 22:12:51 +00:00
fix
This commit is contained in:
parent
18ae5860bc
commit
42ba43fc81
@ -179,6 +179,8 @@
|
|||||||
audioChunks = [];
|
audioChunks = [];
|
||||||
mediaRecorder = false;
|
mediaRecorder = false;
|
||||||
|
|
||||||
|
await tick();
|
||||||
|
|
||||||
if (_continue) {
|
if (_continue) {
|
||||||
startRecording();
|
startRecording();
|
||||||
}
|
}
|
||||||
@ -213,20 +215,24 @@
|
|||||||
const startRecording = async () => {
|
const startRecording = async () => {
|
||||||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||||
mediaRecorder = new MediaRecorder(stream);
|
mediaRecorder = new MediaRecorder(stream);
|
||||||
|
|
||||||
mediaRecorder.onstart = () => {
|
mediaRecorder.onstart = () => {
|
||||||
console.log('Recording started');
|
console.log('Recording started');
|
||||||
audioChunks = [];
|
audioChunks = [];
|
||||||
analyseAudio(stream);
|
analyseAudio(stream);
|
||||||
};
|
};
|
||||||
|
|
||||||
mediaRecorder.ondataavailable = (event) => {
|
mediaRecorder.ondataavailable = (event) => {
|
||||||
if (hasStartedSpeaking) {
|
if (hasStartedSpeaking) {
|
||||||
audioChunks.push(event.data);
|
audioChunks.push(event.data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
mediaRecorder.onstop = async () => {
|
|
||||||
console.log('Recording stopped');
|
mediaRecorder.onstop = (e) => {
|
||||||
await stopRecordingCallback();
|
console.log('Recording stopped', e);
|
||||||
|
stopRecordingCallback();
|
||||||
};
|
};
|
||||||
|
|
||||||
mediaRecorder.start();
|
mediaRecorder.start();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -256,6 +262,8 @@
|
|||||||
let lastSoundTime = Date.now();
|
let lastSoundTime = Date.now();
|
||||||
hasStartedSpeaking = false;
|
hasStartedSpeaking = false;
|
||||||
|
|
||||||
|
console.log('🔊 Sound detection started', lastSoundTime, hasStartedSpeaking);
|
||||||
|
|
||||||
const detectSound = () => {
|
const detectSound = () => {
|
||||||
const processFrame = () => {
|
const processFrame = () => {
|
||||||
if (!mediaRecorder || !$showCallOverlay) {
|
if (!mediaRecorder || !$showCallOverlay) {
|
||||||
@ -288,7 +296,9 @@
|
|||||||
confirmed = true;
|
confirmed = true;
|
||||||
|
|
||||||
if (mediaRecorder) {
|
if (mediaRecorder) {
|
||||||
|
console.log('%c%s', 'color: red; font-size: 20px;', '🔇 Silence detected');
|
||||||
mediaRecorder.stop();
|
mediaRecorder.stop();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -384,6 +394,7 @@
|
|||||||
|
|
||||||
const audioElement = document.getElementById('audioElement');
|
const audioElement = document.getElementById('audioElement');
|
||||||
if (audioElement) {
|
if (audioElement) {
|
||||||
|
audioElement.muted = true;
|
||||||
audioElement.pause();
|
audioElement.pause();
|
||||||
audioElement.currentTime = 0;
|
audioElement.currentTime = 0;
|
||||||
}
|
}
|
||||||
@ -535,6 +546,7 @@
|
|||||||
|
|
||||||
audioAbortController.abort();
|
audioAbortController.abort();
|
||||||
await tick();
|
await tick();
|
||||||
|
|
||||||
await stopAllAudio();
|
await stopAllAudio();
|
||||||
|
|
||||||
await stopRecordingCallback(false);
|
await stopRecordingCallback(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user