ayeberraen narutoelbruto commited on
Commit
7b3d67f
·
0 Parent(s):

Duplicate from speechbrain/google_speech_command_xvector

Browse files

Co-authored-by: naruto bruto <narutoelbruto@users.noreply.huggingface.co>

Files changed (10) hide show
  1. .gitattributes +19 -0
  2. README.md +155 -0
  3. classifier.ckpt +3 -0
  4. config.json +3 -0
  5. embedding_model.ckpt +3 -0
  6. hyperparams.yaml +60 -0
  7. label_encoder.txt +14 -0
  8. normalizer.ckpt +3 -0
  9. stop.wav +0 -0
  10. yes.wav +0 -0
.gitattributes ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
2
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.h5 filter=lfs diff=lfs merge=lfs -text
5
+ *.tflite filter=lfs diff=lfs merge=lfs -text
6
+ *.tar.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.ot filter=lfs diff=lfs merge=lfs -text
8
+ *.onnx filter=lfs diff=lfs merge=lfs -text
9
+ *.arrow filter=lfs diff=lfs merge=lfs -text
10
+ *.ftz filter=lfs diff=lfs merge=lfs -text
11
+ *.joblib filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.pb filter=lfs diff=lfs merge=lfs -text
15
+ *.pt filter=lfs diff=lfs merge=lfs -text
16
+ *.pth filter=lfs diff=lfs merge=lfs -text
17
+ classifier.ckpt filter=lfs diff=lfs merge=lfs -text
18
+ embedding_model.ckpt filter=lfs diff=lfs merge=lfs -text
19
+ normalizer.ckpt filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: "en"
3
+ thumbnail:
4
+ tags:
5
+ - speechbrain
6
+ - embeddings
7
+ - Commands
8
+ - Keywords
9
+ - Keyword Spotting
10
+ - pytorch
11
+ - xvectors
12
+ - TDNN
13
+ - Command Recognition
14
+ - audio-classification
15
+ license: "apache-2.0"
16
+ datasets:
17
+ - GoogleSpeechCommands
18
+ metrics:
19
+ - Accuracy
20
+ widget:
21
+ - example_title: Speech Commands "down"
22
+ src: https://cdn-media.huggingface.co/speech_samples/keyword_spotting_down.wav
23
+ - example_title: Speech Commands "go"
24
+ src: https://cdn-media.huggingface.co/speech_samples/keyword_spotting_go.wav
25
+
26
+ ---
27
+
28
+ <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>
29
+ <br/><br/>
30
+
31
+ # Command Recognition with xvector embeddings on Google Speech Commands
32
+
33
+ This repository provides all the necessary tools to perform command recognition with SpeechBrain using a model pretrained on Google Speech Commands.
34
+ You can download the dataset [here](https://www.tensorflow.org/datasets/catalog/speech_commands)
35
+ The dataset provides small training, validation, and test sets useful for detecting single keywords in short audio clips. The provided system can recognize the following 12 keywords:
36
+ ```
37
+ 'yes', 'no', 'up', 'down', 'left', 'right', 'on', 'off', 'stop', 'go', 'unknown', 'silence'
38
+ ```
39
+
40
+ For a better experience, we encourage you to learn more about
41
+ [SpeechBrain](https://speechbrain.github.io). The given model performance on the test set is:
42
+
43
+ | Release | Accuracy(%)
44
+ |:-------------:|:--------------:|
45
+ | 06-02-21 | 98.14 |
46
+
47
+
48
+ ## Pipeline description
49
+ This system is composed of a TDNN model coupled with statistical pooling. A classifier, trained with Categorical Cross-Entropy Loss, is applied on top of that.
50
+
51
+ The system is trained with recordings sampled at 16kHz (single channel).
52
+ The code will automatically normalize your audio (i.e., resampling + mono channel selection) when calling *classify_file* if needed.
53
+
54
+ ## Install SpeechBrain
55
+
56
+ First of all, please install SpeechBrain with the following command:
57
+
58
+ ```
59
+ pip install speechbrain
60
+ ```
61
+
62
+ Please notice that we encourage you to read our tutorials and learn more about
63
+ [SpeechBrain](https://speechbrain.github.io).
64
+
65
+ ### Perform Command Recognition
66
+
67
+ ```python
68
+ import torchaudio
69
+ from speechbrain.inference.classifiers import EncoderClassifier
70
+ classifier = EncoderClassifier.from_hparams(source="speechbrain/google_speech_command_xvector", savedir="pretrained_models/google_speech_command_xvector")
71
+ out_prob, score, index, text_lab = classifier.classify_file('speechbrain/google_speech_command_xvector/yes.wav')
72
+ print(text_lab)
73
+ out_prob, score, index, text_lab = classifier.classify_file('speechbrain/google_speech_command_xvector/stop.wav')
74
+ print(text_lab)
75
+ ```
76
+
77
+ ### Inference on GPU
78
+ To perform inference on the GPU, add `run_opts={"device":"cuda"}` when calling the `from_hparams` method.
79
+
80
+ ### Training
81
+ The model was trained with SpeechBrain (b7ff9dc4).
82
+ To train it from scratch follows these steps:
83
+ 1. Clone SpeechBrain:
84
+ ```bash
85
+ git clone https://github.com/speechbrain/speechbrain/
86
+ ```
87
+ 2. Install it:
88
+ ```
89
+ cd speechbrain
90
+ pip install -r requirements.txt
91
+ pip install -e .
92
+ ```
93
+
94
+ 3. Run Training:
95
+ ```
96
+ cd recipes/Google-speech-commands
97
+ python train.py hparams/xvect.yaml --data_folder=your_data_folder
98
+ ```
99
+
100
+ You can find our training results (models, logs, etc) [here](https://drive.google.com/drive/folders/1BKwtr1mBRICRe56PcQk2sCFq63Lsvdpc?usp=sharing).
101
+
102
+ ### Limitations
103
+ The SpeechBrain team does not provide any warranty on the performance achieved by this model when used on other datasets.
104
+
105
+ #### Referencing xvectors
106
+ ```@inproceedings{DBLP:conf/odyssey/SnyderGMSPK18,
107
+ author = {David Snyder and
108
+ Daniel Garcia{-}Romero and
109
+ Alan McCree and
110
+ Gregory Sell and
111
+ Daniel Povey and
112
+ Sanjeev Khudanpur},
113
+ title = {Spoken Language Recognition using X-vectors},
114
+ booktitle = {Odyssey 2018},
115
+ pages = {105--111},
116
+ year = {2018},
117
+ }
118
+ ```
119
+
120
+ #### Referencing Google Speech Commands
121
+ ```@article{speechcommands,
122
+ author = { {Warden}, P.},
123
+ title = "{Speech Commands: A Dataset for Limited-Vocabulary Speech Recognition}",
124
+ journal = {ArXiv e-prints},
125
+ archivePrefix = "arXiv",
126
+ eprint = {1804.03209},
127
+ primaryClass = "cs.CL",
128
+ keywords = {Computer Science - Computation and Language, Computer Science - Human-Computer Interaction},
129
+ year = 2018,
130
+ month = apr,
131
+ url = {https://arxiv.org/abs/1804.03209},
132
+ }
133
+ ```
134
+
135
+
136
+ # **About SpeechBrain**
137
+ - Website: https://speechbrain.github.io/
138
+ - Code: https://github.com/speechbrain/speechbrain/
139
+ - HuggingFace: https://huggingface.co/speechbrain/
140
+
141
+
142
+ # **Citing SpeechBrain**
143
+ Please, cite SpeechBrain if you use it for your research or business.
144
+
145
+ ```bibtex
146
+ @misc{speechbrain,
147
+ title={{SpeechBrain}: A General-Purpose Speech Toolkit},
148
+ 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},
149
+ year={2021},
150
+ eprint={2106.04624},
151
+ archivePrefix={arXiv},
152
+ primaryClass={eess.AS},
153
+ note={arXiv:2106.04624}
154
+ }
155
+ ```
classifier.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9cfda9e191640d9e7c67f9c5a2dd60d3beddb917bbc0a70c0e5a8d8d32b6b14b
3
+ size 1096813
config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "speechbrain_interface": "EncoderClassifier"
3
+ }
embedding_model.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:35736f2cc0e6d7562ef2f4c805ee58a91308871bbe76e0cc3efd1c443e114e89
3
+ size 16887676
hyperparams.yaml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ############################################################################
2
+ # Model: xvector for Command Recognition with Google Speech Commands
3
+ # ############################################################################
4
+
5
+ # Pretrain folder (HuggingFace)
6
+ pretrained_path: speechbrain/google_speech_command_xvector
7
+
8
+ # Feature parameters
9
+ n_mels: 24
10
+
11
+ # Output parameters
12
+ out_n_neurons: 12 # 12 command version
13
+
14
+
15
+ # Model params
16
+ compute_features: !new:speechbrain.lobes.features.Fbank
17
+ n_mels: !ref <n_mels>
18
+
19
+ mean_var_norm: !new:speechbrain.processing.features.InputNormalization
20
+ norm_type: sentence
21
+ std_norm: False
22
+
23
+ embedding_model: !new:speechbrain.lobes.models.Xvector.Xvector
24
+ in_channels: !ref <n_mels>
25
+ activation: !name:torch.nn.LeakyReLU
26
+ tdnn_blocks: 5
27
+ tdnn_channels: [512, 512, 512, 512, 1500]
28
+ tdnn_kernel_sizes: [5, 3, 3, 1, 1]
29
+ tdnn_dilations: [1, 2, 3, 1, 1]
30
+ lin_neurons: 512
31
+
32
+ classifier: !new:speechbrain.lobes.models.Xvector.Classifier
33
+ input_shape: [null, null, 512]
34
+ activation: !name:torch.nn.LeakyReLU
35
+ lin_blocks: 1
36
+ lin_neurons: 512
37
+ out_neurons: !ref <out_n_neurons>
38
+
39
+ mean_var_norm_emb: !new:speechbrain.processing.features.InputNormalization
40
+ norm_type: global
41
+ std_norm: False
42
+
43
+ modules:
44
+ compute_features: !ref <compute_features>
45
+ mean_var_norm: !ref <mean_var_norm>
46
+ embedding_model: !ref <embedding_model>
47
+ classifier: !ref <classifier>
48
+
49
+ label_encoder: !new:speechbrain.dataio.encoder.CategoricalEncoder
50
+
51
+
52
+ pretrainer: !new:speechbrain.utils.parameter_transfer.Pretrainer
53
+ loadables:
54
+ embedding_model: !ref <embedding_model>
55
+ classifier: !ref <classifier>
56
+ label_encoder: !ref <label_encoder>
57
+ paths:
58
+ embedding_model: !ref <pretrained_path>/embedding_model.ckpt
59
+ classifier: !ref <pretrained_path>/classifier.ckpt
60
+ label_encoder: !ref <pretrained_path>/label_encoder.txt
label_encoder.txt ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'yes' => 0
2
+ 'no' => 1
3
+ 'up' => 2
4
+ 'down' => 3
5
+ 'left' => 4
6
+ 'right' => 5
7
+ 'on' => 6
8
+ 'off' => 7
9
+ 'stop' => 8
10
+ 'go' => 9
11
+ 'unknown' => 10
12
+ 'silence' => 11
13
+ ================
14
+ 'starting_index' => 0
normalizer.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fcfa59116360f35b6ac5c46242d7ed3a9719892e5e8d314a6f9ae9281c3a2295
3
+ size 1153
stop.wav ADDED
Binary file (45.4 kB). View file
 
yes.wav ADDED
Binary file (23.7 kB). View file