py-webrtcvad Documentation

repository·master·Indexed 25 days ago

https://github.com/wiseman/py-webrtcvad

A Python interface to the Google WebRTC Voice Activity Detector (VAD) used to classify 16-bit mono PCM audio segments as voiced or unvoiced. Supports sample rates of 8000, 16000, 32000, or 48000 Hz with frame durations of 10, 20, or 30 ms.

Tokens
405
Snippets
3
Records
4
Agent score
32%

What's inside py-webrtcvad

  1. How to use py-webrtcvad

    master

    To use the WebRTC Voice Activity Detector, follow these steps:

    1. Initialize the VAD: Create a webrtcvad.Vad() object.
    2. Set Aggressiveness (Optional): Use vad.set_mode(mode) to set the filtering aggressiveness. The mode must 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).
    3. 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.
  2. Vad.is_speech()

    master

    Classifies a short segment of audio as being voiced or unvoiced.

    Parameters:

    • frame: A bytes object containing 16-bit mono PCM audio.
    • sample_rate: The sample rate of the audio (must be 8000, 16000, 32000, or 48000).

    Returns:

    • bool: True if the frame contains speech, False otherwise.
    vad.is_speech(frame, sample_rate)