1.. image:: https://travis-ci.org/wiseman/py-webrtcvad.svg?branch=master 2 :target: https://travis-ci.org/wiseman/py-webrtcvad 3 4py-webrtcvad 5============ 6 7This is a python interface to the WebRTC Voice Activity Detector 8(VAD). It is compatible with Python 2 and Python 3. 9 10A `VAD <https://en.wikipedia.org/wiki/Voice_activity_detection>`_ 11classifies a piece of audio data as being voiced or unvoiced. It can 12be useful for telephony and speech recognition. 13 14The VAD that Google developed for the `WebRTC <https://webrtc.org/>`_ 15project is reportedly one of the best available, being fast, modern 16and free. 17 18How to use it 19------------- 20 210. Install the webrtcvad module:: 22 23 pip install webrtcvad 24 251. Create a ``Vad`` object:: 26 27 import webrtcvad 28 vad = webrtcvad.Vad() 29 302. Optionally, set its aggressiveness mode, which is an integer 31 between 0 and 3. 0 is the least aggressive about filtering out 32 non-speech, 3 is the most aggressive. (You can also set the mode 33 when you create the VAD, e.g. ``vad = webrtcvad.Vad(3)``):: 34 35 vad.set_mode(1) 36 373. Give it a short segment ("frame") of audio. The WebRTC VAD only 38 accepts 16-bit mono PCM audio, sampled at 8000, 16000, or 32000 Hz. 39 A frame must be either 10, 20, or 30 ms in duration:: 40 41 # Run the VAD on 10 ms of silence. The result should be False. 42 sample_rate = 16000 43 frame_duration = 10 # ms 44 frame = b'\x00\x00' * (sample_rate * frame_duration / 1000) 45 print 'Contains speech: %s' % (vad.is_speech(frame, sample_rate) 46 47 48See `example.py 49<https://github.com/wiseman/py-webrtcvad/blob/master/example.py>`_ for 50a more detailed example that will process a .wav file, find the voiced 51segments, and write each one as a separate .wav. 52 53 54How to run unit tests 55--------------------- 56 57To run unit tests:: 58 59 pip install -e ".[dev]" 60 python setup.py test 61