Jzuluaga commited on
Commit
2171138
1 Parent(s): d328e84

First Push!

Browse files
Files changed (6) hide show
  1. hyperparams.yaml +67 -0
  2. README.md +172 -1
  3. accent_encoder.txt +8 -0
  4. config.json +3 -0
  5. model.ckpt +3 -0
  6. normalizer_input.ckpt +3 -0
hyperparams.yaml ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ############################################################################
2
+ # Model: WAV2VEC XLSR model for Accent Recognition (Spanish)
3
+ # see paper: https://arxiv.org/abs/2305.18283
4
+ # ############################################################################
5
+
6
+ # Hparams NEEDED
7
+ HPARAMS_NEEDED: ["encoder_dim", "out_n_neurons", "accent_encoder", "softmax"]
8
+ # Modules Needed
9
+ MODULES_NEEDED: ["wav2vec2", "avg_pool", "output_mlp"]
10
+
11
+ # Feature parameters
12
+ # wav2vec2_hub: facebook/wav2vec2-base
13
+ wav2vec2_hub: "facebook/wav2vec2-large-xlsr-53"
14
+
15
+ # Pretrain folder (HuggingFace)
16
+ pretrained_path: Jzuluaga/accent-id-commonaccent_xlsr-spanish
17
+ # URL for the biggest Fairseq english wav2vec2 model.
18
+
19
+ # parameters
20
+ encoder_dim: 1024
21
+ out_n_neurons: 6
22
+
23
+ wav2vec2: !new:speechbrain.lobes.models.huggingface_wav2vec.HuggingFaceWav2Vec2
24
+ source: !ref <wav2vec2_hub>
25
+ output_norm: True
26
+ freeze: True
27
+ save_path: wav2vec2_checkpoints
28
+
29
+ # Mean and std normalization of the input features
30
+ mean_var_norm_input: !new:speechbrain.processing.features.InputNormalization
31
+ norm_type: sentence
32
+ std_norm: False
33
+
34
+ avg_pool: !new:speechbrain.nnet.pooling.StatisticsPooling
35
+ return_std: False
36
+
37
+ output_mlp: !new:speechbrain.nnet.linear.Linear
38
+ input_size: !ref <encoder_dim>
39
+ n_neurons: !ref <out_n_neurons>
40
+ bias: False
41
+
42
+ model: !new:torch.nn.ModuleList
43
+ - [!ref <output_mlp>]
44
+
45
+ modules:
46
+ mean_var_norm_input: !ref <mean_var_norm_input>
47
+ wav2vec2: !ref <wav2vec2>
48
+ output_mlp: !ref <output_mlp>
49
+ avg_pool: !ref <avg_pool>
50
+
51
+ softmax: !new:speechbrain.nnet.activations.Softmax
52
+
53
+ accent_encoder: !new:speechbrain.dataio.encoder.CategoricalEncoder
54
+
55
+
56
+ pretrainer: !new:speechbrain.utils.parameter_transfer.Pretrainer
57
+ loadables:
58
+ mean_var_norm_input: !ref <mean_var_norm_input>
59
+ wav2vec2: !ref <wav2vec2>
60
+ model: !ref <model>
61
+ accent_encoder: !ref <accent_encoder>
62
+ paths:
63
+ mean_var_norm_input: !ref <pretrained_path>/normalizer_input.ckpt
64
+ wav2vec2: !ref <pretrained_path>/wav2vec2.ckpt
65
+ model: !ref <pretrained_path>/model.ckpt
66
+ accent_encoder: !ref <pretrained_path>/accent_encoder.txt
67
+
README.md CHANGED
@@ -1,3 +1,174 @@
1
  ---
2
- license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ thumbnail:
5
+ tags:
6
+ - audio-classification
7
+ - speechbrain
8
+ - embeddings
9
+ - Accent Identification
10
+ - pytorch
11
+ - wav2vec2
12
+ - XLSR
13
+ - CommonAccent
14
+ license: "mit"
15
+ datasets:
16
+ - CommonVoice
17
+ metrics:
18
+ - Accuracy
19
+ widget:
20
+ - example_title: Caribe-Colombia-Cuba
21
+ src: https://huggingface.co/Jzuluaga/accent-id-commonaccent_xlsr-spanish/resolve/main/data/caribe-cuba-colombia.wav
22
+ - example_title: Andino
23
+ src: https://huggingface.co/Jzuluaga/accent-id-commonaccent_xlsr-spanish/resolve/main/data/andino.wav
24
+ - example_title: Mexico
25
+ src: https://huggingface.co/Jzuluaga/accent-id-commonaccent_xlsr-spanish/resolve/main/data/mexico.wav
26
+ - example_title: Spain
27
+ src: https://huggingface.co/Jzuluaga/accent-id-commonaccent_xlsr-spanish/resolve/main/data/spain.wav
28
  ---
29
+
30
+
31
+ <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>
32
+ <br/><br/>
33
+
34
+ # CommonAccent: Exploring Large Acoustic Pretrained Models for Accent Classification Based on Common Voice
35
+
36
+
37
+ **Abstract**:
38
+ Despite the recent advancements in Automatic Speech Recognition (ASR), the recognition of accented speech still remains a dominant problem. In order to create more inclusive ASR systems, research has shown that the integration of accent information, as part of a larger ASR framework, can lead to the mitigation of accented speech errors. We address multilingual accent classification through the ECAPA-TDNN and Wav2Vec 2.0/XLSR architectures which have been proven to perform well on a variety of speech-related downstream tasks. We introduce a simple-to-follow recipe aligned to the SpeechBrain toolkit for accent classification based on Common Voice 7.0 (English) and Common Voice 11.0 (Italian, German, and Spanish). Furthermore, we establish new state-of-the-art for English accent classification with as high as 95% accuracy. We also study the internal categorization of the Wav2Vev 2.0 embeddings through t-SNE, noting that there is a level of clustering based on phonological similarity.
39
+
40
+
41
+ This repository provides all the necessary tools to perform accent identification from speech recordings with [SpeechBrain](https://github.com/speechbrain/speechbrain).
42
+ The system uses a model pretrained on the CommonAccent dataset in Spanish (6 accents). This system is based on the CommonLanguage Recipe located here: https://github.com/speechbrain/speechbrain/tree/develop/recipes/CommonLanguage
43
+
44
+
45
+ The provided system can recognize the following 16 accents from short speech recordings in Spanish (ES):
46
+
47
+ ```
48
+ - ESPANA SUR PENINSULAR - ANDALUCIA EXTREMADURA MURCIA
49
+ - MEXICO
50
+ - ANDINOPACIFICO COLOMBIA PERU ECUADOR OESTE DE BOLIVIA Y VENEZUELA ANDINA
51
+ - CARIBE CUBA VENEZUELA PUERTO RICO REPUBLICA DOMINICANA PANAMA COLOMBIA CARIBENA MEXICO CARIBENO COSTA DEL GOLFO DE MEXICO
52
+ - RIOPLATENSE ARGENTINA URUGUAY ESTE DE BOLIVIA PARAGUAY
53
+ - CHILENO CHILE CUYO
54
+ ```
55
+
56
+ <a href="https://github.com/JuanPZuluaga/accent-recog-slt2022"> <img alt="GitHub" src="https://img.shields.io/badge/GitHub-Open%20source-green"> </a> Github repository link: https://github.com/JuanPZuluaga/accent-recog-slt2022
57
+
58
+
59
+ For a better experience, we encourage you to learn more about
60
+ [SpeechBrain](https://speechbrain.github.io). The given model performance on the test set is:
61
+
62
+ | Release (dd/mm/yyyy) | Accuracy (%)
63
+ |:-------------:|:--------------:|
64
+ | 01-08-2023 (this model) | 68.5 |
65
+
66
+
67
+ ## Pipeline description
68
+ This system is composed of a fine-tuned XLSR model coupled with statistical pooling. A classifier, trained with NLL Loss, is applied on top of that.
69
+
70
+ The system is trained with recordings sampled at 16kHz (single channel).
71
+ The code will automatically normalize your audio (i.e., resampling + mono channel selection) when calling *classify_file* if needed. Make sure your input tensor is compliant with the expected sampling rate if you use *encode_batch* and *classify_batch*.
72
+
73
+ ## Install SpeechBrain
74
+
75
+ First of all, please install SpeechBrain with the following command:
76
+
77
+ ```
78
+ pip install speechbrain
79
+ ```
80
+
81
+ Please notice that we encourage you to read our tutorials and learn more about
82
+ [SpeechBrain](https://speechbrain.github.io).
83
+
84
+ ### Perform Accent Identification from Speech Recordings
85
+
86
+ ```python
87
+ import torchaudio
88
+ from speechbrain.pretrained import EncoderClassifier
89
+ classifier = EncoderClassifier.from_hparams(source="Jzuluaga/accent-id-commonaccent_xlsr-spanish", savedir="pretrained_models/accent-id-commonaccent_xlsr-spanish")
90
+ # Cuban Accent Example
91
+ out_prob, score, index, text_lab = classifier.classify_file('Jzuluaga/accent-id-commonaccent_xlsr-spanish/data/mexico.wav')
92
+ print(text_lab)
93
+
94
+ # Caribean Example
95
+ out_prob, score, index, text_lab = classifier.classify_file('Jzuluaga/accent-id-commonaccent_xlsr-spanish/data/caribe-cuba-colombia.wav')
96
+ print(text_lab)
97
+ ```
98
+
99
+ ### Inference on GPU
100
+ To perform inference on the GPU, add `run_opts={"device":"cuda"}` when calling the `from_hparams` method.
101
+
102
+ ### Training
103
+
104
+ The model was trained with SpeechBrain.
105
+
106
+ To train it from scratch follow these steps:
107
+
108
+ 1. Clone SpeechBrain:
109
+ ```bash
110
+ git clone https://github.com/speechbrain/speechbrain/
111
+ ```
112
+
113
+ 2. Install it:
114
+ ```bash
115
+ cd speechbrain
116
+ pip install -r requirements.txt
117
+ pip install -e .
118
+ ```
119
+
120
+ 3. Clone our repository in https://github.com/JuanPZuluaga/accent-recog-slt2022:
121
+
122
+ ```bash
123
+ git clone https://github.com/JuanPZuluaga/accent-recog-slt2022
124
+ cd CommonAccent/accent_id
125
+ python train_w2v2.py hparams/train_w2v2.yaml
126
+ ```
127
+
128
+ You can find our training results (models, logs, etc) in this repository's `Files and versions` page.
129
+
130
+ ### Limitations
131
+ The SpeechBrain team does not provide any warranty on the performance achieved by this model when used on other datasets.
132
+
133
+
134
+
135
+ #### Cite our work: CommonAccent
136
+
137
+ If you find useful this work, please cite our work as:
138
+
139
+ ```
140
+ @article{zuluaga2023commonaccent,
141
+ title={CommonAccent: Exploring Large Acoustic Pretrained Models for Accent Classification Based on Common Voice},
142
+ author={Zuluaga-Gomez, Juan and Ahmed, Sara and Visockas, Danielius and Subakan, Cem},
143
+ journal={Interspeech 2023},
144
+ url={https://arxiv.org/abs/2305.18283},
145
+ year={2023}
146
+ }
147
+ ```
148
+
149
+ #### Cite XLSR model
150
+
151
+ ```@article{conneau2020unsupervised,
152
+ title={Unsupervised cross-lingual representation learning for speech recognition},
153
+ author={Conneau, Alexis and Baevski, Alexei and Collobert, Ronan and Mohamed, Abdelrahman and Auli, Michael},
154
+ journal={arXiv preprint arXiv:2006.13979},
155
+ year={2020}
156
+ }
157
+ ```
158
+
159
+
160
+ # **Cite SpeechBrain**
161
+ Please, cite SpeechBrain if you use it for your research or business.
162
+
163
+
164
+ ```bibtex
165
+ @misc{speechbrain,
166
+ title={{SpeechBrain}: A General-Purpose Speech Toolkit},
167
+ 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},
168
+ year={2021},
169
+ eprint={2106.04624},
170
+ archivePrefix={arXiv},
171
+ primaryClass={eess.AS},
172
+ note={arXiv:2106.04624}
173
+ }
174
+ ```
accent_encoder.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ 'ESPANA SUR PENINSULAR (ANDALUCIA EXTREMADURA MURCIA)' => 0
2
+ 'MEXICO' => 1
3
+ 'ANDINOPACIFICO COLOMBIA PERU ECUADOR OESTE DE BOLIVIA Y VENEZUELA ANDINA' => 2
4
+ 'CARIBE CUBA VENEZUELA PUERTO RICO REPUBLICA DOMINICANA PANAMA COLOMBIA CARIBENA MEXICO CARIBENO COSTA DEL GOLFO DE MEXICO' => 3
5
+ 'RIOPLATENSE ARGENTINA URUGUAY ESTE DE BOLIVIA PARAGUAY' => 4
6
+ 'CHILENO CHILE CUYO' => 5
7
+ ================
8
+ 'starting_index' => 0
config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "speechbrain_interface": "EncoderClassifier"
3
+ }
model.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b4d01453d1630748add9fb21725404fef576bac0b98951a049b402908bf866f8
3
+ size 8423259
normalizer_input.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ea5fe8b249fd7932f9e6804b89618f519fac248273d00f0a36470b085c48d7c
3
+ size 1127