Skip to main content

VAD - Simple Voice Activity Detection

Project description

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.5,
) # 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.wav is a sample audio file that can be used to test the package.
  • example_vad.wav is the audio file with only speech after applying the VAD algorithm.
  • example_vad_2.wav is the audio file with only speech direcly extracted from the original audio file using the apply_vad method.
  • vad_output.png is a plot of the voice activity detected by the VAD algorithm.
  • test_vad.py is 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vad-1.0.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

vad-1.0.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file vad-1.0.1.tar.gz.

File metadata

  • Download URL: vad-1.0.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for vad-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d6459f89ed6f034ee3aa221bb1f6f01b4b27b438e314904d35766e7239b57c98
MD5 5b62b454c0edc79edf311144ffb2a0fd
BLAKE2b-256 f739986af83eafab9bed0b9a245a574e9e690cd0fef476a0a584a9f55fa6edcd

See more details on using hashes here.

File details

Details for the file vad-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: vad-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for vad-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce28139dcf6eaf21389a8ab96c761588cf465d87daeaaa123314ff52f3132456
MD5 479d41c98386caf6c6795765233964f6
BLAKE2b-256 2c5b74b1d34c4a4f59d9b991f1ac39bd9d19744cff273bedab46a3a30665201f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page