Jzuluaga commited on
Commit
01f188b
1 Parent(s): 7abd267

Upload 5 files

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