mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 23:21:44 -05:00
[GH-ISSUE #6953] Removing Silence from Audio Files for Local OpenAI/Whisper Models to Prevent Hallucinations #53212
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (Nov 14, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/6953
Proposal for Enhancement in Open WebUI: Silence Removal in Audio Files Before Processing with Whisper Model to Improve Speech Recognition Quality
Dear Developers,
In the current version of Open WebUI (v0.3.35), using local Whisper models for continuous real-time communication can lead to issues. When the Call mode (headphones icon to the right of the microphone) is activated and the user steps away from the computer, the model often listens to extended periods of silence. This situation results in Whisper generating random, nonsensical output when interaction resumes, instead of a meaningful response.
To address this issue, I developed a code that removes silence from audio files before they are processed by the model. This solution avoids "hallucinations" and greatly improves speech recognition quality. It allows for smooth and meaningful interaction with the Open WebUI voice assistant, eliminating unwanted noise and random text. This finally allowed me to communicate in voice assistant mode without the Whisper hallucinations!
Solution Overview:
Solution Overview:
My code was developed specifically for Open WebUI v0.3.35, and I cannot directly submit it to the main development branch, as there are significant differences in code structure that would require adaptation. However, implementing a similar solution in the latest version of WebUI would be extremely beneficial.
Optimization Recommendation: Silence removal could be accelerated using GPU processing, which would offer a significant boost in real-time applications. GPU-based parallel processing would enhance the speed of audio filtering, delivering high-quality and efficient user interaction.
Thank you for your hard work!
This is a repeat request to add audio cleanup, I originally did it here but was told to go here on the development branch. I hope that you will not reject my offer. Perhaps you can do much better sound cleaning than I suggest. I believe in your professionalism. I just want to make Open WebUI better.
https://github.com/open-webui/open-webui/pull/6894
The file and the code in it that I propose to change
open-webui/backend/open_webui/apps/audio /main.py
main.py.txt
import multiprocessing
def remove_silence_from_chunk(audio_chunk):
Removes silence from an audio chunk.
def remove_silence(audio):
# Removes silence from an audio file by splitting it into chunks and processing them in parallel.
chunk_size = 5000 # chunk size in milliseconds
chunks = [audio[i:i+chunk_size] for i in range(0, len(audio), chunk_size)]
def transcribe(file_path):
# Processes an audio file: removes silence and performs transcription.
print("Transcribing", file_path)
@nphalem commented on GitHub (Dec 11, 2024):
Why don't you make a pull request from this instead of opening an issue?
@SirBadfish commented on GitHub (Dec 20, 2024):
I'm just copy-pasting my comment from another thread here about this same issue:
Yeah, I just can't get the Whisper hallucinations to go away no matter what I do. It ruins OWUI entirely for me and makes it unusable for my purposes. "Thank you." gets added to everything I say. Sometimes, "Thank you. Thank you. Thank you." gets added. I thought it might be because I was using OWUI within Pinkokio, so I switched to a Docker install. I thought maybe it was my mic, my device, a bad wire, the Whisper model I was using, etc. Nothing I do gets it to go away. Happens on my Macbook Pro M1 Max 64gb, and on my PC w a 4090 as well. I've spent a good 8 hours troubleshooting this issue at this point, but it very much seems to be the way it's implemented into OWUI and not something on my end.
@nengoxx commented on GitHub (Dec 30, 2024):
I used a workaround for the hallucinations, in the audio.py you can add the VAD filter to the transcribe function call:
segments, info = model.transcribe(file_path, language="en", beam_size=5, vad_filter=True).Another solution would be to use faster-whisper-server instead of local whisper, it seems to have that silence removal functionality implemented, but still gets a bit too many hallucinations without adding the VAD parameter.
@SirBadfish commented on GitHub (Dec 31, 2024):
@nengoxx yeah this:
I used a workaround for the hallucinations, in the audio.py you can add the VAD filter to the transcribe function call:
segments, info = model.transcribe(file_path, language="en", beam_size=5, vad_filter=True)... you mentioned this to me on Reddit also and it works great... Like it 100% resolved the hallucinations for me. Anyone that hasn't made this quick edit needs to try it. Just find the OWUI file named
audio.pyinside of thebackend > open_webui > routerfolder and edit line 468 to the above and you are golden.@TomBayne commented on GitHub (Apr 13, 2025):
I created a PR for this change. Seems like a no-brainer with no real downsides.