VAD - simple voice activity detection in Python
This is a simple voice activity detection (VAD) algorithm in Python. It is based on simple energy-based thresholding and is intended to be used as a simple method for detecting speech in audio files when other methods cannot be used for both privacy, performance, or other reasons.
Installation
You can install the package using pip:
pip install vad
Usage
The package can be seamlessly integrated into your Python code. The following example shows how to use the package to detect speech in an audio file:
from vad import EnergyVAD
# load audio file in "audio" variable
vad = EnergyVAD(
sample_rate: int = 16000,
frame_length: int = 25, # in milliseconds
frame_shift: int = 20, # in milliseconds
energy_threshold: float = 0.05, # you may need to adjust this value
pre_emphasis: float = 0.95,
) # default values are used here
voice_activity = vad(audio) # returns a boolean array indicating whether a frame is speech or not
# you can also use the following method to get the audio file with only speech
# speech_signal is a numpy array of the same shape as audio
speech_signal = vad.apply_vad(audio)
Audio samples
example.wavis a sample audio file that can be used to test the package.example_vad.wavis the audio file with only speech after applying the VAD algorithm.example_vad_2.wavis the audio file with only speech direcly extracted from the original audio file using theapply_vadmethod.vad_output.pngis a plot of the voice activity detected by the VAD algorithm.test_vad.pyis the script that was used to generate the above audio files and plot.
Known issues
- There is no additional VAD algorithm implemented in this package at the moment. It may be added in the future.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for vad 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| vad-1.0.2.tar.gz | 3.8 kB | Without provenance | Details for vad-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vad-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for vad-1.0.2-py3-none-any.whl |
Total release size: 7.9 kB
Release files / vad-1.0.2.tar.gz
| Download URL | vad-1.0.2.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
45f94be198842febf678bd9dbd5bf425d9e8ab59f8f1eb21e8d6e92e469bdce6
|
|
BLAKE2b-256 checksum How to use checksums |
328db9aa2bddfcac4a455ea1543124b2545b197dde2f6749b3182045f0a4d4b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / vad-1.0.2-py3-none-any.whl
| Download URL | vad-1.0.2-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80f59cd32c446e592e1b21373eb604304aee42b2e44bfef2b75a9b2d84a1f7a8
|
|
BLAKE2b-256 checksum How to use checksums |
2deb44f99d15727e51ecfbdcbf69b8ef74de08dc5db93a7a430b0f9eeda08c6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Security for vad 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.