https://github.com/rhasspy/energy-vad
Energy-based voice activity detector with no dependencies
https://github.com/rhasspy/energy-vad
Last synced: 10 days ago
JSON representation
Energy-based voice activity detector with no dependencies
- Host: GitHub
- URL: https://github.com/rhasspy/energy-vad
- Owner: rhasspy
- License: mit
- Created: 2024-07-18T19:53:25.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2024-07-29T15:45:36.000Z (9 months ago)
- Last Synced: 2025-04-09T02:48:12.085Z (16 days ago)
- Language: Python
- Size: 321 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Energy VAD
Simple energy-based voice activity detector (VAD) with no external dependencies.
Energy threshold is calibrated from initial audio, or can be set manually.
## Installation
``` sh
pip install energy-vad
```## Example
``` python
import wave
from energy_vad import EnergyVadvad = EnergyVad()
with wave.open("test.wav", "rb") as wav_file:
assert wav_file.getframerate() == 16000
assert wav_file.getsampwidth() == 2
assert wav_file.getnchannels() == 1
chunk = wav_file.readframes(vad.samples_per_chunk)
while len(chunk) == vad.bytes_per_chunk:
result = vad.process_chunk(chunk)
if result is None:
# calibrating
pass
elif result:
# speech
print("!", end="")
else:
# silence
print(".", end="")chunk = wav_file.readframes(vad.samples_per_chunk)
print("")
print("Energy threshold:", vad.threshold)# Clear calibrated threshold
vad.reset_calibration()
```