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
7eaf83cb
Commit
7eaf83cb
authored
Jun 06, 2024
by
Timothy J. Baek
Browse files
fix: silence monitoring
parent
4a73a01c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
src/lib/components/chat/MessageInput/VoiceRecording.svelte
src/lib/components/chat/MessageInput/VoiceRecording.svelte
+16
-0
No files found.
src/lib/components/chat/MessageInput/VoiceRecording.svelte
View file @
7eaf83cb
...
...
@@ -80,12 +80,17 @@
audioStreamSource.connect(analyser);
const bufferLength = analyser.frequencyBinCount;
const domainData = new Uint8Array(bufferLength);
const timeDomainData = new Uint8Array(analyser.fftSize);
let lastSoundTime = Date.now();
const detectSound = () => {
const processFrame = () => {
if (recording && !loading) {
analyser.getByteTimeDomainData(timeDomainData);
analyser.getByteFrequencyData(domainData);
// Calculate RMS level from time domain data
const rmsLevel = calculateRMS(timeDomainData);
...
...
@@ -98,6 +103,16 @@
}
visualizerData = visualizerData;
if (domainData.some((value) => value > 0)) {
lastSoundTime = Date.now();
}
if (recording && Date.now() - lastSoundTime > 3000) {
if ($settings?.speechAutoSend ?? false) {
confirmRecording();
}
}
}
window.requestAnimationFrame(processFrame);
...
...
@@ -203,6 +218,7 @@
rounded-full"
on:click={async () => {
dispatch('cancel');
stopRecording();
}}
>
<svg
...
...
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