marsbroshok/VAD-python
Voice Activity Detector in Python
What it solves
VAD-python detects when a person is speaking in an audio file or live stream. It solves three common problems: feeding long silences into speech-to-text models (like Whisper) wastes money and makes the model hallucinate; high-end neural VADs are heavy, needing large model files and GPU libraries; and trimming silence from recordings manually is tedious. This tool provides a fast, lightweight, and transparent alternative.
How it works
The detector uses classic digital signal processing (DSP) instead of deep learning. It takes audio, splits it into 20-millisecond windows, and for each window calculates two things: the overall loudness (RMS) and the fraction of energy that falls in the human speech frequency band (300–3000 Hz). A window is marked as speech if the loudness is above a low floor and the speech-band energy ratio is above a threshold (default 0.6). A median filter of 0.5 seconds smooths out short clicks or pauses. The result is a list of time intervals where speech occurs, which can be used to produce a silence-stripped WAV file or real-time events.
Who it’s for
- Developers building voice agents or speech-to-text pipelines who want a cheap first-stage gate before sending audio to a heavy model.
- People who need to clean up podcast recordings, TTS outputs, or meeting audio by removing dead air.
- Hobbyists and students learning how signal processing works in Python, since the code is about 250 readable lines with adjustable parameters.
Highlights
- No heavy dependencies: only
numpyis required for detection;scipyandmatplotlibare optional. - Zero model weights – starts instantly on any machine, works in cloud functions or containers.
- Processes a 1-hour audio file in milliseconds.
- Provides both a Python API and a command-line interface.
- Includes a streaming mode (
StreamingVAD) to gate live microphone chunks frame-by-frame. - Fully white-box: you can tweak the frequency band, thresholds, or window size and plot the results.
Related
- Project
- Project
- Project
- Project