Skip to content

Commit 8c48d79

Browse files
authored
Merge pull request #18 from Sinica-SLAM/feature/channel_adapt
Feature/channel adapt
2 parents 1735a2b + 55bae90 commit 8c48d79

40 files changed

Lines changed: 13410 additions & 1 deletion
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Speaker recognition experiments with VoxCeleb.
2+
This folder contains scripts for running speaker identification and verification experiments with the VoxCeleb dataset(http://www.robots.ox.ac.uk/~vgg/data/voxceleb/).
3+
4+
# Training Xvectors
5+
Run the following command to train xvectors:
6+
7+
`python train_speaker_embeddings.py hparams/train_x_vectors.yaml`
8+
9+
You can use the same script for voxceleb1, voxceleb2, and voxceleb1+2. Just change the datafolder and the corresponding number of speakers (1211 vox1, 5994 vox2, 7205 vox1+2).
10+
For voxceleb1 + voxceleb2, see preparation instructions below).
11+
12+
The system trains a TDNN for speaker embeddings coupled with a speaker-id classifier. The speaker-id accuracy should be around 97-98% for both voxceleb1 and voceleb2.
13+
14+
# Speaker verification with PLDA
15+
After training the speaker embeddings, it is possible to perform speaker verification using PLDA. You can run it with the following command:
16+
17+
`python speaker_verification_plda.py hparams/verification_plda_xvector.yaml`
18+
19+
If you didn't train the speaker embedding before, we automatically download the xvector model from the web.
20+
This system achieves an EER = 3.2% on voxceleb1 + voxceleb2.
21+
These results are all obtained with the official verification split of voxceleb1 (veri\_split.txt)
22+
23+
24+
# Speaker verification using ECAPA-TDNN embeddings
25+
Run the following command to train speaker embeddings using [ECAPA-TDNN](https://arxiv.org/abs/2005.07143):
26+
27+
`python train_speaker_embeddings.py hparams/train_ecapa_tdnn.yaml`
28+
29+
30+
The speaker-id accuracy should be around 98-99% for both voxceleb1 and voceleb2.
31+
32+
After training the speaker embeddings, it is possible to perform speaker verification using cosine similarity. You can run it with the following command:
33+
34+
`python speaker_verification_cosine.py hparams/verification_ecapa.yaml`
35+
36+
This system achieves an EER = 0.69 % on voxceleb1 + voxceleb2.
37+
These results are all obtained with the official verification split of voxceleb1 (veri\_split.txt)
38+
39+
# VoxCeleb2 preparation
40+
Voxceleb2 audio files are released in m4a format. All the files must be converted in wav files before
41+
feeding them is SpeechBrain. Please, follow these steps to prepare the dataset correctly:
42+
43+
1. Download both Voxceleb1 and Voxceleb2.
44+
You can find download instructions here: http://www.robots.ox.ac.uk/~vgg/data/voxceleb/
45+
Note that for the speaker verification experiments with Voxceleb2 the official split of voxceleb1 is used to compute EER.
46+
47+
2. Convert .m4a to wav
48+
Voxceleb2 stores files with the m4a audio format. To use them within SpeechBrain you have to convert all the m4a files into wav files.
49+
You can do the conversion using ffmpeg(see for instance conversion scripts in https://gitmemory.com/issue/pytorch/audio/104/493137979 or https://gist.github.com/seungwonpark/4f273739beef2691cd53b5c39629d830). This operation might take several hours and should be only once.
50+
51+
2. Put all the wav files in a folder called wav. You should have something like `voxceleb2/wav/id*/*.wav` (e.g, `voxceleb2/wav/id00012/21Uxsk56VDQ/00001.wav`)
52+
53+
3. copy the `voxceleb1/vox1_test_wav.zip` file into the voxceleb2 folder.
54+
55+
4. Unpack voxceleb1 test files(verification split).
56+
57+
Go to the voxceleb2 folder and run `unzip vox1_test_wav.zip`.
58+
59+
5. Copy the verification split(`voxceleb1/ meta/veri_test.txt`) into voxceleb2(`voxceleb2/meta/ veri_test.txt`)
60+
61+
6. Now everything is ready and you can run voxceleb2 experiments:
62+
- training embeddings:
63+
64+
`python train_speaker_embeddings.py hparams/train_xvectors.yaml`
65+
66+
Note: To prepare the voxceleb1 + voxceleb2 dataset you have to copy and unpack vox1_dev_wav.zip for the voxceleb1 dataset.
67+
68+
# Performance summary
69+
70+
[Speaker Verification Results with Voxceleb 1 + Voxceleb2]
71+
| System | Dataset | EER | Link |
72+
|-----------------|------------|------| -----|
73+
| Xvector + PLDA | VoxCeleb 1,2 | 3.2% | - |
74+
| ECAPA-TDNN | Voxceleb 1,2 | 0.69% | - |
75+
76+
77+
# PreTrained Model + Easy-Inference
78+
You can find the pre-trained model with an easy-inference function on [HuggingFace](https://huggingface.co/speechbrain/spkrec-ecapa-voxceleb).
79+
80+
# **About SpeechBrain**
81+
- Website: https://speechbrain.github.io/
82+
- Code: https://github.com/speechbrain/speechbrain/
83+
- HuggingFace: https://huggingface.co/speechbrain/
84+
85+
86+
# **Citing SpeechBrain**
87+
Please, cite SpeechBrain if you use it for your research or business.
88+
89+
```bibtex
90+
@misc{speechbrain,
91+
title={{SpeechBrain}: A General-Purpose Speech Toolkit},
92+
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},
93+
year={2021},
94+
eprint={2106.04624},
95+
archivePrefix={arXiv},
96+
primaryClass={eess.AS},
97+
note={arXiv:2106.04624}
98+
}
99+
```
100+
101+
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# ################################
2+
# Model: Speaker identification with ECAPA
3+
# Authors: Hwidong Na & Mirco Ravanelli
4+
# ################################
5+
6+
# Basic parameters
7+
seed: 1986
8+
__set_seed: !apply:torch.manual_seed [!ref <seed>]
9+
output_folder: !ref results/ecapa_augment/<seed>
10+
save_folder: !ref <output_folder>/save
11+
train_log: !ref <output_folder>/train_log.txt
12+
13+
# Data files
14+
data_folder: !PLACEHOLDER # e.g. /path/to/Voxceleb
15+
train_annotation: !ref <save_folder>/train.csv
16+
valid_annotation: !ref <save_folder>/dev.csv
17+
18+
# Folder to extract data augmentation files
19+
rir_folder: !ref <data_folder> # Change it if needed
20+
21+
# Use the following links for the official voxceleb splits:
22+
# VoxCeleb1 (cleaned): https://www.robots.ox.ac.uk/~vgg/data/voxceleb/meta/veri_test2.txt
23+
# VoxCeleb1-H (cleaned): https://www.robots.ox.ac.uk/~vgg/data/voxceleb/meta/list_test_hard2.txt
24+
# VoxCeleb1-E (cleaned): https://www.robots.ox.ac.uk/~vgg/data/voxceleb/meta/list_test_all2.txt.
25+
# VoxCeleb1-E and VoxCeleb1-H lists are drawn from the VoxCeleb1 training set.
26+
# Therefore you cannot use any files in VoxCeleb1 for training if you are using these lists for testing.
27+
verification_file: https://www.robots.ox.ac.uk/~vgg/data/voxceleb/meta/veri_test2.txt
28+
29+
skip_prep: False
30+
ckpt_interval_minutes: 15 # save checkpoint every N min
31+
32+
# Training parameters
33+
number_of_epochs: 10
34+
batch_size: 32
35+
lr: 0.001
36+
base_lr: 0.00000001
37+
max_lr: !ref <lr>
38+
step_size: 65000
39+
sample_rate: 16000
40+
sentence_len: 3.0 # seconds
41+
shuffle: True
42+
random_chunk: True
43+
44+
# Feature parameters
45+
n_mels: 80
46+
left_frames: 0
47+
right_frames: 0
48+
deltas: False
49+
50+
# Number of speakers
51+
out_n_neurons: 7205 #1211 for vox1 # 5994 for vox2, 7205 for vox1+vox2
52+
53+
dataloader_options:
54+
batch_size: !ref <batch_size>
55+
shuffle: !ref <shuffle>
56+
num_workers: 2
57+
58+
# Functions
59+
compute_features: !new:speechbrain.lobes.features.Fbank
60+
n_mels: !ref <n_mels>
61+
left_frames: !ref <left_frames>
62+
right_frames: !ref <right_frames>
63+
deltas: !ref <deltas>
64+
65+
embedding_model: !new:speechbrain.lobes.models.ECAPA_TDNN.ECAPA_TDNN
66+
input_size: !ref <n_mels>
67+
channels: [1024, 1024, 1024, 1024, 3072]
68+
kernel_sizes: [5, 3, 3, 3, 1]
69+
dilations: [1, 2, 3, 4, 1]
70+
attention_channels: 128
71+
lin_neurons: 192
72+
73+
classifier: !new:speechbrain.lobes.models.ECAPA_TDNN.Classifier
74+
input_size: 192
75+
out_neurons: !ref <out_n_neurons>
76+
77+
epoch_counter: !new:speechbrain.utils.epoch_loop.EpochCounter
78+
limit: !ref <number_of_epochs>
79+
80+
81+
augment_wavedrop: !new:speechbrain.lobes.augment.TimeDomainSpecAugment
82+
sample_rate: !ref <sample_rate>
83+
speeds: [100]
84+
85+
augment_speed: !new:speechbrain.lobes.augment.TimeDomainSpecAugment
86+
sample_rate: !ref <sample_rate>
87+
speeds: [95, 100, 105]
88+
89+
add_rev: !new:speechbrain.lobes.augment.EnvCorrupt
90+
openrir_folder: !ref <rir_folder>
91+
openrir_max_noise_len: 3.0 # seconds
92+
reverb_prob: 1.0
93+
noise_prob: 0.0
94+
noise_snr_low: 0
95+
noise_snr_high: 15
96+
rir_scale_factor: 1.0
97+
98+
add_noise: !new:speechbrain.lobes.augment.EnvCorrupt
99+
openrir_folder: !ref <rir_folder>
100+
openrir_max_noise_len: 3.0 # seconds
101+
reverb_prob: 0.0
102+
noise_prob: 1.0
103+
noise_snr_low: 0
104+
noise_snr_high: 15
105+
rir_scale_factor: 1.0
106+
107+
add_rev_noise: !new:speechbrain.lobes.augment.EnvCorrupt
108+
openrir_folder: !ref <rir_folder>
109+
openrir_max_noise_len: 3.0 # seconds
110+
reverb_prob: 1.0
111+
noise_prob: 1.0
112+
noise_snr_low: 0
113+
noise_snr_high: 15
114+
rir_scale_factor: 1.0
115+
116+
117+
# Definition of the augmentation pipeline.
118+
# If concat_augment = False, the augmentation techniques are applied
119+
# in sequence. If concat_augment = True, all the augmented signals
120+
# # are concatenated in a single big batch.
121+
122+
augment_pipeline: [
123+
!ref <augment_wavedrop>,
124+
!ref <augment_speed>,
125+
!ref <add_rev>,
126+
!ref <add_noise>,
127+
!ref <add_rev_noise>
128+
]
129+
concat_augment: True
130+
131+
mean_var_norm: !new:speechbrain.processing.features.InputNormalization
132+
norm_type: sentence
133+
std_norm: False
134+
135+
modules:
136+
compute_features: !ref <compute_features>
137+
augment_wavedrop: !ref <augment_wavedrop>
138+
augment_speed: !ref <augment_speed>
139+
add_rev: !ref <add_rev>
140+
add_noise: !ref <add_noise>
141+
add_rev_noise: !ref <add_rev_noise>
142+
embedding_model: !ref <embedding_model>
143+
classifier: !ref <classifier>
144+
mean_var_norm: !ref <mean_var_norm>
145+
146+
compute_cost: !new:speechbrain.nnet.losses.LogSoftmaxWrapper
147+
loss_fn: !new:speechbrain.nnet.losses.AdditiveAngularMargin
148+
margin: 0.2
149+
scale: 30
150+
151+
compute_error: !name:speechbrain.nnet.losses.classification_error
152+
153+
opt_class: !name:torch.optim.Adam
154+
lr: !ref <lr>
155+
weight_decay: 0.000002
156+
157+
lr_annealing: !new:speechbrain.nnet.schedulers.CyclicLRScheduler
158+
base_lr: !ref <base_lr>
159+
max_lr: !ref <max_lr>
160+
step_size: !ref <step_size>
161+
162+
# Logging + checkpoints
163+
train_logger: !new:speechbrain.utils.train_logger.FileTrainLogger
164+
save_file: !ref <train_log>
165+
166+
error_stats: !name:speechbrain.utils.metric_stats.MetricStats
167+
metric: !name:speechbrain.nnet.losses.classification_error
168+
reduction: batch
169+
170+
checkpointer: !new:speechbrain.utils.checkpoints.Checkpointer
171+
checkpoints_dir: !ref <save_folder>
172+
recoverables:
173+
embedding_model: !ref <embedding_model>
174+
classifier: !ref <classifier>
175+
normalizer: !ref <mean_var_norm>
176+
counter: !ref <epoch_counter>

0 commit comments

Comments
 (0)