Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
42ba43fc
Commit
42ba43fc
authored
Jun 14, 2024
by
Timothy J. Baek
Browse files
fix
parent
18ae5860
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
src/lib/components/chat/MessageInput/CallOverlay.svelte
src/lib/components/chat/MessageInput/CallOverlay.svelte
+15
-3
No files found.
src/lib/components/chat/MessageInput/CallOverlay.svelte
View file @
42ba43fc
...
@@ -179,6 +179,8 @@
...
@@ -179,6 +179,8 @@
audioChunks = [];
audioChunks = [];
mediaRecorder = false;
mediaRecorder = false;
await tick();
if (_continue) {
if (_continue) {
startRecording();
startRecording();
}
}
...
@@ -213,20 +215,24 @@
...
@@ -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 @@
...
@@ -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 @@
...
@@ -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 @@
...
@@ -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 @@
...
@@ -535,6 +546,7 @@
audioAbortController.abort();
audioAbortController.abort();
await tick();
await tick();
await stopAllAudio();
await stopAllAudio();
await stopRecordingCallback(false);
await stopRecordingCallback(false);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment