Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Py-WebRTCvad
https://github.com/wiseman/py-webrtcvad
Admin
Python interface to the WebRTC Voice Activity Detector
Tokens:
511
Snippets:
6
Trust Score:
9.6
License:
MIT
Update:
4 months ago
Context
Chat
Benchmark
78
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Installing py-webrtcvad with pip Source: https://github.com/wiseman/py-webrtcvad/blob/master/README.rst This command demonstrates how to install the py-webrtcvad library using the pip package manager. This is the standard way to get the library installed on your system. ```Shell pip install webrtcvad ``` -------------------------------- ### Importing and Initializing WebRTC VAD in Python Source: https://github.com/wiseman/py-webrtcvad/blob/master/README.rst This Python snippet shows how to import the webrtcvad module and create an instance of the Vad class. This is the first step to using the VAD functionality after installation. ```Python import webrtcvad vad = webrtcvad.Vad() ``` -------------------------------- ### Installing py-webrtcvad for Development with pip Source: https://github.com/wiseman/py-webrtcvad/blob/master/README.rst This command installs the py-webrtcvad package in editable mode along with its development dependencies. This is typically used when contributing to or modifying the library source code. ```Shell pip install -e ".[dev]" ``` -------------------------------- ### Running Unit Tests for py-webrtcvad Source: https://github.com/wiseman/py-webrtcvad/blob/master/README.rst This command executes the unit tests defined for the py-webrtcvad library. It requires the development dependencies to be installed (e.g., using the previous step). ```Shell python setup.py test ``` -------------------------------- ### Checking if an Audio Frame Contains Speech with WebRTC VAD Source: https://github.com/wiseman/py-webrtcvad/blob/master/README.rst This Python example shows how to create a silent audio frame and use the `is_speech` method to check for voice activity. The method requires the audio frame as a bytes object and the sample rate, and it returns True if speech is detected, False otherwise. The VAD only accepts 16-bit mono PCM audio frames of 10, 20, or 30 ms duration at specific sample rates. ```Python # 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) ``` -------------------------------- ### Setting Aggressiveness Mode for WebRTC VAD Source: https://github.com/wiseman/py-webrtcvad/blob/master/README.rst This Python code demonstrates how to set the aggressiveness mode of the VAD object. The mode is an integer from 0 (least aggressive) to 3 (most aggressive) and affects how strongly non-speech is filtered out. ```Python vad.set_mode(1) ```