Self-contained voice activity detector (VAD) that uses the machine learning architecture from microWakeWord.
pip install pymicro-vad
from pymicro_vad import MicroVad
vad = MicroVad()
threshold = 0.5
# Process 10ms chunks of 16-bit mono PCM @16Khz
while audio := get_10ms_of_audio():
assert len(audio) == 160 * 2 # 160 samples
speech_prob = vad.Process10ms(audio)
if speech_prob < 0:
print("Need more audio")
elif speech_prob > threshold:
print("Speech")
else:
print("Silence")
Ensure you have python3-dev
and build-essential
installed.
Run script/setup
to create a virtual environment, then script/build
to build the extension locally.