webrtcvad-wheels

Python interface to the Google WebRTC Voice Activity Detector (VAD) [released with binary wheels!]


Keywords
speechrecognition, asr, voiceactivitydetection, vad, webrtc
License
MIT
Install
pip install webrtcvad-wheels==2.0.10.post2

Documentation

PyPI Version Supported Python Versions Wheel Support Downloads per Month Build Status Donate via PayPal Sponsor on GitHub

py-webrtcvad-wheels

This is a python interface to the WebRTC Voice Activity Detector (VAD). It is forked from wiseman/py-webrtcvad to provide updated releases with binary wheels for Windows, macOS, and Linux. Also includes additional fixes and improvements.

A VAD classifies a piece of audio data as being voiced or unvoiced. It can be useful for telephony and speech recognition.

The VAD that Google developed for the WebRTC project is reportedly one of the best available, being fast, modern and free.

How to use it

  1. Install the webrtcvad module:

    pip install webrtcvad-wheels
    
  2. Create a Vad object:

    import webrtcvad
    vad = webrtcvad.Vad()
    
  3. Optionally, set its aggressiveness mode, which is an integer between 0 and 3 (inclusive). 0 is the least aggressive about filtering out non-speech, 3 is the most aggressive. (You can also set the mode when you create the VAD, e.g. vad = webrtcvad.Vad(3); the default is 0):

    vad.set_mode(1)
    
  4. Give it a short segment ("frame") of audio. The WebRTC VAD only accepts 16-bit mono PCM audio, sampled at 8000, 16000, 32000 or 48000 Hz. A frame must be either 10, 20, or 30 ms in duration:

    # Run the VAD on 10 ms of silence. The result should be False.
    sample_rate = 16000
    frame_duration = 10  # ms
    frame = b'\x00\x00' * int(sample_rate * frame_duration / 1000)
    print 'Contains speech: %s' % (vad.is_speech(frame, sample_rate)
    

See example.py for a more detailed example that will process a .wav file, find the voiced segments, and write each one as a separate .wav.

How to run unit tests

To run unit tests:

pip install -e ".[dev]"
python setup.py test

History

2.0.14

  • Add RISC-V support (but no wheels yet). Thanks, hack3ric!
  • Add loongarch64 support (but no wheels yet). Thanks, zhangwenlong8911!

2.0.13

  • Add tests for memory leaks.
  • Fix memory leak in constructing Vad objects. Thanks, manipopopo!

2.0.12

  • Add Python 3.12 & 3.13 builds.
  • Fix pkg_resources usage for Python 3.12+.

2.0.11.post1

  • Force build of new wheels.

2.0.11

  • Fix out-of-bounds memory read in WebRtcVad_FindMinimum.
  • Add Python 3.10 & 3.11 builds.
  • Add PPC support & builds.
  • Implement CI/CD with GitHub Actions instead.

2.0.10.post2

  • Revert updating to the latest webrtcvad upstream version, as it breaks build.
  • Tweak CI/CD configuration.
  • Add Python 3.9 build.

2.0.10.post1

  • Merge various changes from upstream.
  • Implement CI/CD with Travis CI.

FORK

2.0.10

  • Fixed memory leak. Thank you, bond005!

2.0.9

  • Improved example code. Added WebRTC license.

2.0.8

  • Fixed Windows compilation errors. Thank you, xiongyihui!