speechbrainteam commited on
Commit
5c9ce57
1 Parent(s): 0c039f8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +191 -1
README.md CHANGED
@@ -1 +1,191 @@
1
- Work in Progress
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Work in Progress
2
+
3
+
4
+ ---
5
+ language: "en"
6
+ thumbnail:
7
+ tags:
8
+ - speechbrain
9
+ - VAD
10
+ - SAD
11
+ - Voice Activity Detection
12
+ - Speech Activity Detection
13
+ - Speaker Diarization
14
+ - pytorch
15
+ - CRDNN
16
+ - LibriSpeech
17
+ - LibryParty
18
+ datasets:
19
+ - Urbansound8k
20
+ metrics:
21
+ - Accuracy
22
+
23
+ ---
24
+
25
+ <iframe src="https://ghbtns.com/github-btn.html?user=speechbrain&repo=speechbrain&type=star&count=true&size=large&v=2" frameborder="0" scrolling="0" width="170" height="30" title="GitHub"></iframe>
26
+ <br/><br/>
27
+
28
+ # Voice Activity Detection with a (small) CRDNN model trained on Libriparty
29
+
30
+ This repository provides all the necessary tools to perform voice activity detection with SpeechBrain using a model pretrained on Libriparty
31
+
32
+ The pre-trained system can process short and long speech recordings and outputs the segments where speech activity is detected.
33
+ The output of the system looks like this:
34
+
35
+ ```
36
+ segment_001 0.00 2.57 NON_SPEECH
37
+ segment_002 2.57 8.20 SPEECH
38
+ segment_003 8.20 9.10 NON_SPEECH
39
+ segment_004 9.10 10.93 SPEECH
40
+ segment_005 10.93 12.00 NON_SPEECH
41
+ segment_006 12.00 14.40 SPEECH
42
+ segment_007 14.40 15.00 NON_SPEECH
43
+ segment_008 15.00 17.70 SPEECH
44
+ ```
45
+
46
+ For a better experience, we encourage you to learn more about
47
+ [SpeechBrain](https://speechbrain.github.io).
48
+
49
+ # Results
50
+ The model performance on the LibriParty test set is:
51
+
52
+ | Release | hyperparams file | Test Precision | Test Recall | Test F-Score | Model link | GPUs |
53
+ |:-------------:|:---------------------------:| -----:| -----:| --------:| :-----------:| :-----------:|
54
+ | 2021-09-09 | train.yaml | 0.939 | 0.951 | 0.945 | https://drive.google.com/drive/folders/1Z7J3Zd7M5M9VYoNtbrbpbxSoKWUpjhzp?usp=sharing | 1xV100 16GB
55
+
56
+
57
+ ## Pipeline description
58
+ 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.
59
+ A threshold is applied on top of the posteriors to detect candidate speech boundaries.
60
+
61
+ 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.
62
+
63
+ ## Install SpeechBrain
64
+
65
+ First of all, please install SpeechBrain with the following command:
66
+
67
+ ```
68
+ pip install speechbrain
69
+ ```
70
+
71
+ Please notice that we encourage you to read our tutorials and learn more about
72
+ [SpeechBrain](https://speechbrain.github.io).
73
+
74
+ ### Perform Voice Activity Detection
75
+
76
+ ```python
77
+ from speechbrain.pretrained import VAD
78
+
79
+ VAD = VAD.from_hparams(source="speechbrain/vad_crdnn_libriparty", savedir="pretrained_models/vad_crdnn_libriparty")
80
+ boundaries = VAD.get_speech_segments("speechbrain/vad_example.wav")
81
+
82
+ # Print the output
83
+ VAD.save_boundaries(boundaries)
84
+ ```
85
+ The output is a tensor that contains the beginning/end second of each
86
+ detected speech segment. You can save the boundaries on a file with:
87
+
88
+ ```python
89
+ VAD.save_boundaries(boundaries, save_path='VAD_file.txt')
90
+ ```
91
+
92
+ 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.
93
+
94
+ To do it:
95
+
96
+ ```python
97
+ upsampled_boundaries = VAD.upsample_boundaries(boundaries, audio_file)
98
+ torchaudio.save('vad_final.wav', upsampled_boundaries.cpu(), sample_rate)
99
+ ```
100
+
101
+ This creates a "VAD signal" with the same dimensionality as the original signal.
102
+
103
+ You can now open *vad_final.wav* and *speechbrain/vad_example.wav* with software like audacity to visualize them jointly.
104
+
105
+
106
+ ### VAD pipeline details
107
+ The pipeline for detecting the speech segments is the following:
108
+ 1. Compute posteriors probabilities at the frame level.
109
+ 2. Apply a threshold on the posterior probability.
110
+ 3. Derive candidate speech segments on top of that.
111
+ 4. Apply energy VAD within each candidate segment (optional). This might break down long sentences into short one based on the energy content.
112
+ 5. Merge segments that are too close.
113
+ 6. Remove segments that are too short.
114
+ 7. Double-check speech segments (optional). This could is a final check to make sure the detected segments are actually speech ones.
115
+
116
+ We designed the VAD such that you can have access to all of these steps (this might help to debug):
117
+
118
+
119
+ ```python
120
+
121
+ # 1- Let's compute frame-level posteriors first
122
+ prob_chunks = VAD.get_speech_prob_file(audio_file)
123
+
124
+ # 2- Let's apply a threshold on top of the posteriors
125
+ prob_th = VAD.apply_threshold(prob_chunks).float()
126
+
127
+ # 3- Let's now derive the candidate speech segments
128
+ boundaries = VAD.get_boundaries(prob_th)
129
+
130
+ # 4- Apply energy VAD within each candidate speech segment (optional)
131
+
132
+ boundaries = VAD.energy_VAD(audio_file,boundaries)
133
+
134
+ # 5- Merge segments that are too close
135
+ boundaries = VAD.merge_short_segments(boundaries, close_th=0.250)
136
+
137
+ # 6- Re,ove segments that are too short
138
+ boundaries = VAD.remove_short_segments(boundaries, len_th=0.250)
139
+
140
+ # 7- Double-check speech segments (optional).
141
+ boundaries = VAD.double_check_speech_segments(boundaries, audio_file, speech_th=0.5)
142
+ ```
143
+
144
+
145
+ ### Inference on GPU
146
+ To perform inference on the GPU, add `run_opts={"device":"cuda"}` when calling the `from_hparams` method.
147
+
148
+ ### Training
149
+ The model was trained with SpeechBrain (ea17d22).
150
+ To train it from scratch follows these steps:
151
+ 1. Clone SpeechBrain:
152
+ ```bash
153
+ git clone https://github.com/speechbrain/speechbrain/
154
+ ```
155
+ 2. Install it:
156
+ ```
157
+ cd speechbrain
158
+ pip install -r requirements.txt
159
+ pip install -e .
160
+ ```
161
+
162
+ 3. Run Training:
163
+ Training heavily relies on data augmentation. Make sure you have downloaded all the datasets needed:
164
+
165
+ - LibriParty: https://drive.google.com/file/d/1--cAS5ePojMwNY5fewioXAv9YlYAWzIJ/view?usp=sharing
166
+ - Musan: https://www.openslr.org/resources/17/musan.tar.gz
167
+ - CommonLanguage: https://zenodo.org/record/5036977/files/CommonLanguage.tar.gz?download=1
168
+
169
+ ```
170
+ cd recipes/LibriParty/VAD
171
+ python train.py hparams/train.yaml --data_folder=/path/to/LibriParty --musan_folder=/path/to/musan/ --commonlanguage_folder=/path/to/common_voice_kpd
172
+ ```
173
+
174
+ ### Limitations
175
+ The SpeechBrain team does not provide any warranty on the performance achieved by this model when used on other datasets.
176
+
177
+ # **Citing SpeechBrain**
178
+ Please, cite SpeechBrain if you use it for your research or business.
179
+
180
+
181
+ ```bibtex
182
+ @misc{speechbrain,
183
+ title={{SpeechBrain}: A General-Purpose Speech Toolkit},
184
+ 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},
185
+ year={2021},
186
+ eprint={2106.04624},
187
+ archivePrefix={arXiv},
188
+ primaryClass={eess.AS},
189
+ note={arXiv:2106.04624}
190
+ }
191
+ ```