Jzuluaga commited on
Commit
2dcf25f
1 Parent(s): 09e93a4

First push!

Browse files
Files changed (4) hide show
  1. README.md +192 -0
  2. accent_encoder.txt +18 -0
  3. hyperparams.yaml +67 -0
  4. model.ckpt +3 -0
README.md CHANGED
@@ -1,3 +1,195 @@
1
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ thumbnail: null
5
+ tags:
6
+ - audio-classification
7
+ - speechbrain
8
+ - embeddings
9
+ - Accent Identification
10
+ - pytorch
11
+ - wav2vec2
12
+ - XLSR
13
+ - CommonAccent
14
+ - English
15
  license: mit
16
+ datasets:
17
+ - CommonVoice
18
+ metrics:
19
+ - Accuracy
20
+ widget:
21
+ - example_title: USA
22
+ src: >-
23
+ https://huggingface.co/Jzuluaga/accent-id-commonaccent_xlsr-en-english/resolve/main/data/us.wav
24
+ - example_title: Scotland
25
+ src: >-
26
+ https://huggingface.co/Jzuluaga/accent-id-commonaccent_xlsr-en-english/resolve/main/data/scotland.wav
27
+ - example_title: Malaysia
28
+ src: >-
29
+ https://huggingface.co/Jzuluaga/accent-id-commonaccent_xlsr-en-english/resolve/main/data/malaysia.wav
30
+ - example_title: HongKong
31
+ src: >-
32
+ https://huggingface.co/Jzuluaga/accent-id-commonaccent_xlsr-en-english/resolve/main/data/hongkong.wav
33
+ - example_title: Philippines
34
+ src: >-
35
+ https://huggingface.co/Jzuluaga/accent-id-commonaccent_xlsr-en-english/resolve/main/data/philippines.wav
36
  ---
37
+
38
+
39
+ <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>
40
+ <br/><br/>
41
+
42
+
43
+ # CommonAccent: Exploring Large Acoustic Pretrained Models for Accent Classification Based on CommonVoice
44
+
45
+ **English Accent Classifier with XLSR model**
46
+
47
+
48
+ **Abstract**:
49
+ 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.
50
+
51
+
52
+ This repository provides all the necessary tools to perform accent identification from speech recordings with [SpeechBrain](https://github.com/speechbrain/speechbrain).
53
+ The system uses a model pretrained on the CommonAccent dataset in English (16 accents). This system is based on the CommonLanguage Recipe located here: https://github.com/speechbrain/speechbrain/tree/develop/recipes/CommonLanguage
54
+
55
+
56
+ The provided system can recognize the following 16 accents from short speech recordings in English (EN):
57
+
58
+ ```
59
+ - us
60
+ - england
61
+ - australia
62
+ - indian
63
+ - canada
64
+ - bermuda
65
+ - scotland
66
+ - african
67
+ - ireland
68
+ - newzealand
69
+ - wales
70
+ - malaysia
71
+ - philippines
72
+ - singapore
73
+ - hongkong
74
+ - southatlandtic
75
+ ```
76
+
77
+ <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
78
+
79
+
80
+ **NOTE**: due to incompatibility with the model and the current SpeechBrain interfaces, we cannot offer the Inference API. Please, follow the steps in **"Perform Accent Identification from Speech Recordings"** to use this Italian Accent ID model.
81
+
82
+ For a better experience, we encourage you to learn more about
83
+ [SpeechBrain](https://speechbrain.github.io).
84
+
85
+
86
+ ## Pipeline description
87
+ 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.
88
+
89
+ The system is trained with recordings sampled at 16kHz (single channel).
90
+ 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*.
91
+
92
+ ## Install SpeechBrain
93
+
94
+ First of all, please install SpeechBrain with the following command:
95
+
96
+ ```
97
+ pip install speechbrain
98
+ ```
99
+
100
+ Please notice that we encourage you to read our tutorials and learn more about
101
+ [SpeechBrain](https://speechbrain.github.io).
102
+
103
+ ### Perform Accent Identification from Speech Recordings
104
+
105
+ ```python
106
+ import torchaudio
107
+ from speechbrain.pretrained.interfaces import foreign_class
108
+
109
+ classifier = foreign_class(source="Jzuluaga/accent-id-commonaccent_xlsr-en-english", pymodule_file="custom_interface.py", classname="CustomEncoderWav2vec2Classifier")
110
+
111
+ # US Accent Example
112
+ out_prob, score, index, text_lab = classifier.classify_file('Jzuluaga/accent-id-commonaccent_xlsr-en-english/data/us.wav')
113
+ print(text_lab)
114
+
115
+ # Philippines Example
116
+ out_prob, score, index, text_lab = classifier.classify_file('Jzuluaga/accent-id-commonaccent_xlsr-en-english/data/philippines.wav')
117
+ print(text_lab)
118
+ ```
119
+
120
+ ### Inference on GPU
121
+ To perform inference on the GPU, add `run_opts={"device":"cuda"}` when calling the `from_hparams` method.
122
+
123
+ ### Training
124
+
125
+ The model was trained with SpeechBrain.
126
+
127
+ To train it from scratch follow these steps:
128
+
129
+ 1. Clone SpeechBrain:
130
+ ```bash
131
+ git clone https://github.com/speechbrain/speechbrain/
132
+ ```
133
+
134
+ 2. Install it:
135
+ ```bash
136
+ cd speechbrain
137
+ pip install -r requirements.txt
138
+ pip install -e .
139
+ ```
140
+
141
+ 3. Clone our repository in https://github.com/JuanPZuluaga/accent-recog-slt2022:
142
+
143
+ ```bash
144
+ git clone https://github.com/JuanPZuluaga/accent-recog-slt2022
145
+ cd CommonAccent/accent_id
146
+ python train_w2v2.py hparams/train_w2v2.yaml
147
+ ```
148
+
149
+ You can find our training results (models, logs, etc) in this repository's `Files and versions` page.
150
+
151
+ ### Limitations
152
+ The SpeechBrain team does not provide any warranty on the performance achieved by this model when used on other datasets.
153
+
154
+
155
+
156
+ #### Cite our work: CommonAccent
157
+
158
+ If you find useful this work, please cite our work as:
159
+
160
+ ```
161
+ @article{zuluaga2023commonaccent,
162
+ title={CommonAccent: Exploring Large Acoustic Pretrained Models for Accent Classification Based on Common Voice},
163
+ author={Zuluaga-Gomez, Juan and Ahmed, Sara and Visockas, Danielius and Subakan, Cem},
164
+ journal={Interspeech 2023},
165
+ url={https://arxiv.org/abs/2305.18283},
166
+ year={2023}
167
+ }
168
+ ```
169
+
170
+ #### Cite XLSR model
171
+
172
+ ```@article{conneau2020unsupervised,
173
+ title={Unsupervised cross-lingual representation learning for speech recognition},
174
+ author={Conneau, Alexis and Baevski, Alexei and Collobert, Ronan and Mohamed, Abdelrahman and Auli, Michael},
175
+ journal={arXiv preprint arXiv:2006.13979},
176
+ year={2020}
177
+ }
178
+ ```
179
+
180
+
181
+ # **Cite SpeechBrain**
182
+ Please, cite SpeechBrain if you use it for your research or business.
183
+
184
+
185
+ ```bibtex
186
+ @misc{speechbrain,
187
+ title={{SpeechBrain}: A General-Purpose Speech Toolkit},
188
+ 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},
189
+ year={2021},
190
+ eprint={2106.04624},
191
+ archivePrefix={arXiv},
192
+ primaryClass={eess.AS},
193
+ note={arXiv:2106.04624}
194
+ }
195
+ ```
accent_encoder.txt ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'us' => 0
2
+ 'england' => 1
3
+ 'australia' => 2
4
+ 'indian' => 3
5
+ 'canada' => 4
6
+ 'bermuda' => 5
7
+ 'scotland' => 6
8
+ 'african' => 7
9
+ 'ireland' => 8
10
+ 'newzealand' => 9
11
+ 'wales' => 10
12
+ 'malaysia' => 11
13
+ 'philippines' => 12
14
+ 'singapore' => 13
15
+ 'hongkong' => 14
16
+ 'southatlandtic' => 15
17
+ ================
18
+ 'starting_index' => 0
hyperparams.yaml ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ############################################################################
2
+ # Model: WAV2VEC XLSR model for Accent Recognition (Italian)
3
+ # see paper: https://arxiv.org/abs/2305.18283
4
+ # ############################################################################
5
+
6
+ # Hparams NEEDED
7
+ HPARAMS_NEEDED: ["encoder_dim", "out_n_neurons", "label_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-en-english
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_emb: !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_emb: !ref <mean_var_norm_emb>
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
+ label_encoder: !new:speechbrain.dataio.encoder.CategoricalEncoder
54
+
55
+
56
+ pretrainer: !new:speechbrain.utils.parameter_transfer.Pretrainer
57
+ loadables:
58
+ mean_var_norm_emb: !ref <mean_var_norm_emb>
59
+ wav2vec2: !ref <wav2vec2>
60
+ model: !ref <model>
61
+ label_encoder: !ref <label_encoder>
62
+ paths:
63
+ mean_var_norm_emb: !ref <pretrained_path>/normalizer_input.ckpt
64
+ wav2vec2: !ref <pretrained_path>/wav2vec2.ckpt
65
+ model: !ref <pretrained_path>/model.ckpt
66
+ label_encoder: !ref <pretrained_path>/label_encoder.txt
67
+
model.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52128f15268f3fb8dc61798447b2e1aaee72806707d5f8b26b14766a87778e82
3
+ size 66411