A high-precision, low-latency Voice Activity Detection (VAD) and automated audio recording engine built entirely on Digital Signal Processing (DSP) principles without external machine learning, cloud dependencies, or neural network overhead.
[Raw Audio Stream] (16kHz, 16-bit PCM)
│
▼
[30ms Window Partitioning] (480 samples/frame)
│
▼
[Fast Fourier Transform (FFT)] ──► Real-to-Complex Frequency Domain (np.fft.rfft)
│
▼
[Bandpass Masking] ──────────────► Zero-out frequencies < 300Hz and > 3400Hz (Vocal Tract)
│
▼
[Inverse FFT (np.fft.irfft)] ────► Cleaned time-domain acoustic waveform
│
▼
[RMS Energy Calculation] ────────► E_rms = sqrt( (1/N) * sum( x[i]^2 ) )
│
▼
[Adaptive Silence Decision Engine] ─► Stops recording after trailing silence threshold
- Zero Latency: Operates in real-time per 30ms window with sub-millisecond execution overhead.
- Minimal Footprint: No PyTorch, TensorFlow, or ONNX runtimes. Consumes less than 25MB RAM.
- Bandpass Isolation: Suppresses low-frequency mechanical rumble (< 300Hz) and high-frequency hiss (> 3400Hz), isolating the fundamental formants of human speech.
- Dynamic Ambient Calibration: Automatically measures background acoustic levels on startup to adapt the speech threshold.
git clone https://github.com/Gaoc3/VoiceDetection.git
cd VoiceDetection
pip install -r requirements.txtpython voice_detector.py --output my_recording.wav --silence 2.0from voice_detector import AcousticVoiceDetector
detector = AcousticVoiceDetector(
sample_rate=16000,
silence_sec=2.3
)
# Automatically calibrates noise and records until silence
detector.record_until_silence("meeting_note.wav")| Parameter | Type | Default | Description |
|---|---|---|---|
sample_rate |
int |
16000 |
Audio sampling rate in Hertz. |
frame_ms |
int |
30 |
Analysis window chunk size in milliseconds. |
low_cutoff_hz |
float |
300.0 |
Lower bandpass frequency bound (human voice band). |
high_cutoff_hz |
float |
3400.0 |
Upper bandpass frequency bound. |
silence_sec |
float |
2.3 |
Trailing silence duration before stopping recording. |
rms_threshold |
float |
500.0 |
Base speech sensitivity threshold (dynamically calibrated). |