How to use py-webrtcvad
masterTo use the WebRTC Voice Activity Detector, follow these steps:
- Initialize the VAD: Create a
webrtcvad.Vad()object. - Set Aggressiveness (Optional): Use
vad.set_mode(mode)to set the filtering aggressiveness. Themodemust be an integer between 0 and 3.0: Least aggressive (least likely to filter out non-speech).3: Most aggressive (most likely to filter out non-speech).- You can also pass the mode directly during initialization:
webrtcvad.Vad(mode).
- Process Audio Frames: Use
vad.is_speech(frame, sample_rate)to classify a segment of audio.
Audio Requirements:
- Format: 16-bit mono PCM audio.
- Sample Rates: Must be exactly 8000, 16000, 32000, or 48000 Hz.
- Frame Duration: Each frame must be exactly 10, 20, or 30 ms in duration.