Lightweight RMS-based Voice Activity Detection for ASR pipelines
Project description
rms-vad
Lightweight RMS-based Voice Activity Detection for ASR pipelines.
Zero-dependency core (only audioop from stdlib). Optional numpy for faster multi-channel conversion.
Features
- Zero dependencies - only uses
audioopfrom Python stdlib - Adaptive threshold - automatically adjusts to ambient noise levels
- Pre-buffering - captures audio before speech onset to avoid clipping leading phonemes
- Multiple API styles - event-driven, callback, and iterator interfaces
- Multi-channel support - auto-converts to mono (optional
numpyacceleration) - Lightweight & fast - pure Python, minimal CPU overhead
Installation
pip install rms-vad
# With numpy (recommended for multi-channel audio)
pip install rms-vad[numpy]
Quick Start
Event-driven style
from rms_vad import RmsVAD, VADConfig, VADEventType
vad = RmsVAD(VADConfig(threshold=0.5, attack=0.2, release=1.5))
for chunk in mic_stream:
for event in vad.feed(chunk):
if event.type == VADEventType.SPEECH_START:
asr.start()
for frame in event.pre_buffer:
asr.send(frame)
elif event.type == VADEventType.AUDIO:
asr.send(event.chunk)
elif event.type == VADEventType.SPEECH_END:
asr.end()
Callback style
vad = RmsVAD(VADConfig(threshold=0.3))
vad.on_speech_start = lambda pre_buf: asr.start()
vad.on_audio = lambda chunk: asr.send(chunk)
vad.on_speech_end = lambda: asr.end()
for chunk in mic_stream:
vad.feed(chunk)
Iterator style
for event in vad.iter_events(mic_stream):
...
Configuration
| Parameter | Default | Description |
|---|---|---|
sample_rate |
16000 | Audio sample rate (Hz) |
sample_width |
2 | Bytes per sample (2 = 16-bit PCM) |
channels |
1 | Audio channels (auto-converts to mono) |
chunk_size |
1024 | Samples per chunk |
max_level |
25000 | RMS normalization baseline |
threshold |
0.5 | Initial VAD threshold (0.0~1.0) |
attack |
0.2 | Seconds before speech onset confirmed |
release |
1.5 | Seconds of silence before speech end |
history_size |
500 | RMS history buffer size |
avg_window |
30 | Frames for moving average |
pre_buffer_size |
10 | Pre-activation frame count |
adapt_up_rate |
0.0025 | Threshold slow-rise rate |
adapt_down_rate |
1.0 | Threshold fast-drop rate |
hysteresis_multiply |
1.05 | History percentage multiplier |
hysteresis_offset |
0.02 | History percentage offset |
Algorithm
- RMS calculation -
audioop.rms(buffer, 2)on each chunk, normalized to[0, 1] - Moving average - 30-frame window with hysteresis (
*1.05 + 0.02) - Adaptive threshold - asymmetric: slow rise (0.25%/frame), fast drop (100%/frame)
- State machine -
SILENCE <-> SPEAKINGwith attack/release debouncing - Pre-buffer - captures audio before speech onset to avoid clipping leading phonemes
Requirements
- Python >= 3.8
- No required dependencies (uses
audioopfrom stdlib) - Optional:
numpyfor efficient multi-channel to mono conversion
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Setup
git clone https://github.com/akkoaya/rms-vad.git
cd rms-vad
pip install -e ".[dev]"
pytest
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rms_vad-0.1.0.tar.gz.
File metadata
- Download URL: rms_vad-0.1.0.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7820574e2dd518a4ad2c4072bc5e8820abebc27a56a4bfd9de55658425f0bd7c
|
|
| MD5 |
643b81dd6402fa9533f56e57cfa75822
|
|
| BLAKE2b-256 |
07ac792183a8e195f5f6aed681dde230d12c80452367093d394154471d17e74e
|
Provenance
The following attestation bundles were made for rms_vad-0.1.0.tar.gz:
Publisher:
publish.yml on akkoaya/rms-vad
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rms_vad-0.1.0.tar.gz -
Subject digest:
7820574e2dd518a4ad2c4072bc5e8820abebc27a56a4bfd9de55658425f0bd7c - Sigstore transparency entry: 1003356429
- Sigstore integration time:
-
Permalink:
akkoaya/rms-vad@4f583ada8f1cb336bf051a6d7e0266d25259637f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/akkoaya
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4f583ada8f1cb336bf051a6d7e0266d25259637f -
Trigger Event:
release
-
Statement type:
File details
Details for the file rms_vad-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rms_vad-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1721510b69f3cf946bd08efa88dde6824ea63f09cda2303093e09ea6669dc706
|
|
| MD5 |
140ecd19dff7a977a8c1395421a4bad4
|
|
| BLAKE2b-256 |
79965f4e475a9a6484a6c17047eefc5e070303f4b9be28ad47f356592a5ec3ad
|
Provenance
The following attestation bundles were made for rms_vad-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on akkoaya/rms-vad
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rms_vad-0.1.0-py3-none-any.whl -
Subject digest:
1721510b69f3cf946bd08efa88dde6824ea63f09cda2303093e09ea6669dc706 - Sigstore transparency entry: 1003356434
- Sigstore integration time:
-
Permalink:
akkoaya/rms-vad@4f583ada8f1cb336bf051a6d7e0266d25259637f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/akkoaya
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4f583ada8f1cb336bf051a6d7e0266d25259637f -
Trigger Event:
release
-
Statement type: