Skip to main content

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

  1. Clone or download this repository
  2. Navigate to the bensilence folder
  3. Install dependencies:
    pip install -r requirements.txt
    
  4. 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

Metadata

Release files for bensilence 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bensilence 2.0.0
File Size Uploaded Provenance Actions
bensilence-2.0.0.tar.gz 6.4 kB Without provenance Details for bensilence-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bensilence 2.0.0
File Interpreter ABI Platform Actions
bensilence-2.0.0-py3-none-any.whl Python 3 none any Details for bensilence-2.0.0-py3-none-any.whl

Total release size: 12.5 kB

Release files / bensilence-2.0.0.tar.gz

Download URL bensilence-2.0.0.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
029ba5b66b73802405cf43206edcc32c2336a398180ce8b79a519e3bdb983e03
BLAKE2b-256 checksum
How to use checksums
3eb3327739a0521cb8498db9417b8103ce73e44188befade999038607ee4f31c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / bensilence-2.0.0-py3-none-any.whl

Download URL bensilence-2.0.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce6e0ad867a6795cd5cd716819bed672d14506326281754c36e47e570e53aa2c
BLAKE2b-256 checksum
How to use checksums
6715e0ba439521dde1df50e8a4135a7effa90ec7cc7468dac60cf3bf718d5daf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Security for bensilence 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page