A voice activity detection based audio recorder library using Silero VAD
Project description
bensilence
A voice activity detection (VAD) based audio recorder library. It automatically starts recording when speech is detected and stops when silence occurs. Perfect for AI assistants and voice applications.
This library uses Silero VAD for voice activity detection, providing high-quality speech detection without requiring API keys.
Features
- Voice Activity Detection: Uses Silero VAD for accurate speech detection
- Pre-buffering: Capture audio from before speech detection starts
- Configurable Sensitivity: Adjust detection sensitivity (1-3 levels)
- Silence Threshold: Customizable silence duration before stopping
- Time Limits: Maximum recording time protection
- Easy Integration: Simple API for quick implementation
Installation
Install from PyPI/GitHub (Recommended)
pip install git+https://github.com/benimrans/bensilence.git
Install from source
- Clone or download this repository
- Navigate to the bensilence folder
- Install dependencies:
pip install -r requirements.txt
- Install the package:
pip install .
Usage
Basic Usage
from bensilence import SilenceRecorder
# Create recorder
recorder = SilenceRecorder(file_name="my_recording.wav")
recorder.initialize()
# Start recording (waits for voice, records until silence)
result, filename = recorder.record()
print(f"Recording result: {result}")
if filename:
print(f"Saved to: {filename}")
# Clean up
recorder.cleanup()
Advanced Usage
from bensilence import silence
# Create recorder with custom settings
recorder = silence(
file_name="output.wav",
before_seconds=2, # Include 2 seconds before speech starts
max_sensitivity=2, # Medium sensitivity
max_recording_time=60, # Max 60 seconds
silence_threshold=1.5 # Stop after 1.5 seconds of silence
)
recorder.initialize()
result, filename = recorder.record()
recorder.cleanup()
Configuration Parameters
file_name: Output filename (default: "output.wav")before_seconds: Seconds of audio to include before speech detection (default: 0)max_sensitivity: Detection sensitivity 1-3 (default: 2)- 1: Less sensitive (0.3 threshold)
- 2: Medium sensitivity (0.5 threshold)
- 3: More sensitive (0.7 threshold)
max_recording_time: Maximum recording duration in seconds (default: 30)silence_threshold: Seconds of silence before stopping (default: 1)
Dependencies
- numpy: For audio data processing
- pyaudio: For audio input/output
- soundfile: For WAV file handling
- torch: For Silero VAD model
License
MIT License - see LICENSE file for details
Related Projects
- rhasspy-silence - WebRTC-based VAD
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 bensilence-2.0.0.tar.gz.
File metadata
- Download URL: bensilence-2.0.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
029ba5b66b73802405cf43206edcc32c2336a398180ce8b79a519e3bdb983e03
|
|
| MD5 |
be30eca3e52b5969484ff3cca9830e1c
|
|
| BLAKE2b-256 |
3eb3327739a0521cb8498db9417b8103ce73e44188befade999038607ee4f31c
|
File details
Details for the file bensilence-2.0.0-py3-none-any.whl.
File metadata
- Download URL: bensilence-2.0.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce6e0ad867a6795cd5cd716819bed672d14506326281754c36e47e570e53aa2c
|
|
| MD5 |
ec325eeefaa747be3724d4946dd4cd5b
|
|
| BLAKE2b-256 |
6715e0ba439521dde1df50e8a4135a7effa90ec7cc7468dac60cf3bf718d5daf
|