Pyvad is a Python wrapper for the `py-webrtcvad` library, designed for trimming speech clips from audio. It provides a simplified interface for Voice Activity Detection (VAD) functionality, allowing users to identify and extract voiced segments from audio data. The current version is 0.2.0, released in July 2022, with an infrequent release cadence.
pip install pyvadVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `pyvad` to perform Voice Activity Detection and trim silence from a simulated audio clip. It generates a sample audio array with speech and silence segments, then applies the `vad` and `trim` functions. The `vad` function returns an array indicating voiced/unvoiced segments, and `trim` returns the audio with leading/trailing silence removed, along with the start and end indices of the speech.
Ensure your Python environment is 3.8 or 3.9. Update your code to use `hop_length` instead of `hoplength` and adjust calls to `trim` to expect `(start_index, end_index)` as the second return value instead of relying on `return_sec`. Review the `example.ipynb` on GitHub for the latest API usage.
Always ensure your input audio data (`data` and `fs`) and specified VAD parameters (`fs_vad`, `hop_length`, `vad_mode`) adhere to these constraints. Resample your audio to one of the supported `fs_vad` rates if necessary, and normalize `float` data to the -1.0 to 1.0 range or ensure `int` data fits the 16-bit PCM range. Use `librosa.resample` for resampling.
When calling `vad` or `trim`, set `vad_mode` to 0, 1, 2, or 3 based on your desired aggressiveness. Default is 0.