Voice Activity Detection with a (small) CRDNN model trained on Libriparty
This repository provides all the necessary tools to perform voice activity detection with SpeechBrain using a model pretrained on Libriparty.
The pre-trained system can process short and long speech recordings and outputs the segments where speech activity is detected.
The output of the system looks like this:
The system expects input recordings sampled at 16kHz (single channel).
If your signal has a different sample rate, resample it (e.g., using torchaudio or sox) before using the interface.
For a better experience, we encourage you to learn more about
SpeechBrain
.
Results
The model performance on the LibriParty test set is:
This system is composed of a CRDNN that outputs posteriors probabilities with a value close to one for speech frames and close to zero for non-speech segments.
A threshold is applied on top of the posteriors to detect candidate speech boundaries.
Depending on the active options, these boundaries can be post-processed (e.g, merging close segments, removing short segments, etc) to further improve the performance. See more details below.
Install SpeechBrain
pip install speechbrain
Please notice that we encourage you to read our tutorials and learn more about
SpeechBrain
.
Perform Voice Activity Detection
from speechbrain.inference.VAD import VAD
VAD = VAD.from_hparams(source="speechbrain/vad-crdnn-libriparty", savedir="pretrained_models/vad-crdnn-libriparty")
boundaries = VAD.get_speech_segments("speechbrain/vad-crdnn-libriparty/example_vad.wav")
# Print the output
VAD.save_boundaries(boundaries)
The output is a tensor that contains the beginning/end second of each
detected speech segment. You can save the boundaries on a file with:
Sometimes it is useful to jointly visualize the VAD output with the input signal itself. This is helpful to quickly figure out if the VAD is doing or not a good job.
This creates a "VAD signal" with the same dimensionality as the original signal.
You can now open
vad_final.wav
and
pretrained_model_checkpoints/example_vad.wav
with software like audacity to visualize them jointly.
VAD pipeline details
The pipeline for detecting the speech segments is the following:
Compute posteriors probabilities at the frame level.
Apply a threshold on the posterior probability.
Derive candidate speech segments on top of that.
Apply energy VAD within each candidate segment (optional). This might break down long sentences into short one based on the energy content.
Merge segments that are too close.
Remove segments that are too short.
Double-check speech segments (optional). This could is a final check to make sure the detected segments are actually speech ones.
We designed the VAD such that you can have access to all of these steps (this might help to debug):
from speechbrain.inference.VAD import VAD
VAD = VAD.from_hparams(source="speechbrain/vad-crdnn-libriparty", savedir="pretrained_models/vad-crdnn-libriparty")
# 1- Let's compute frame-level posteriors first
audio_file = "example.wav"
prob_chunks = VAD.get_speech_prob_file(audio_file)
# 2- Let's apply a threshold on top of the posteriors
prob_th = VAD.apply_threshold(prob_chunks).float()
# 3- Let's now derive the candidate speech segments
boundaries = VAD.get_boundaries(prob_th)
# 4- Apply energy VAD within each candidate speech segment (optional)
boundaries = VAD.energy_VAD(audio_file,boundaries)
# 5- Merge segments that are too close
boundaries = VAD.merge_close_segments(boundaries, close_th=0.250)
# 6- Remove segments that are too short
boundaries = VAD.remove_short_segments(boundaries, len_th=0.250)
# 7- Double-check speech segments (optional).
boundaries = VAD.double_check_speech_segments(boundaries, audio_file, speech_th=0.5)
Inference on GPU
To perform inference on the GPU, add
run_opts={"device":"cuda"}
when calling the
from_hparams
method.
Training
The model was trained with SpeechBrain (ea17d22).
To train it from scratch follows these steps:
cd recipes/LibriParty/VAD
python train.py hparams/train.yaml --data_folder=/path/to/LibriParty --musan_folder=/path/to/musan/ --commonlanguage_folder=/path/to/common_voice_kpd
Limitations
The SpeechBrain team does not provide any warranty on the performance achieved by this model when used on other datasets.
Citing SpeechBrain
Please, cite SpeechBrain if you use it for your research or business.
@misc{speechbrain,
title={{SpeechBrain}: A General-Purpose Speech Toolkit},
author={Mirco Ravanelli and Titouan Parcollet and Peter Plantinga and Aku Rouhe and Samuele Cornell and Loren Lugosch and Cem Subakan and Nauman Dawalatabad and Abdelwahab Heba and Jianyuan Zhong and Ju-Chieh Chou and Sung-Lin Yeh and Szu-Wei Fu and Chien-Feng Liao and Elena Rastorgueva and François Grondin and William Aris and Hwidong Na and Yan Gao and Renato De Mori and Yoshua Bengio},
year={2021},
eprint={2106.04624},
archivePrefix={arXiv},
primaryClass={eess.AS},
note={arXiv:2106.04624}
}
Runs of speechbrain vad-crdnn-libriparty on huggingface.co
13.2K
Total runs
-216
24-hour runs
-331
3-day runs
-751
7-day runs
-3.7K
30-day runs
More Information About vad-crdnn-libriparty huggingface.co Model
vad-crdnn-libriparty huggingface.co
vad-crdnn-libriparty huggingface.co is an AI model on huggingface.co that provides vad-crdnn-libriparty's model effect (), which can be used instantly with this speechbrain vad-crdnn-libriparty model. huggingface.co supports a free trial of the vad-crdnn-libriparty model, and also provides paid use of the vad-crdnn-libriparty. Support call vad-crdnn-libriparty model through api, including Node.js, Python, http.
vad-crdnn-libriparty huggingface.co is an online trial and call api platform, which integrates vad-crdnn-libriparty's modeling effects, including api services, and provides a free online trial of vad-crdnn-libriparty, you can try vad-crdnn-libriparty online for free by clicking the link below.
speechbrain vad-crdnn-libriparty online free url in huggingface.co:
vad-crdnn-libriparty is an open source model from GitHub that offers a free installation service, and any user can find vad-crdnn-libriparty on GitHub to install. At the same time, huggingface.co provides the effect of vad-crdnn-libriparty install, users can directly use vad-crdnn-libriparty installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
vad-crdnn-libriparty install url in huggingface.co: