elgeish commited on
Commit
f142d8d
1 Parent(s): 468dce7

upload files

Browse files
README.md ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ datasets:
4
+ - timit_asr
5
+ tags:
6
+ - audio
7
+ - automatic-speech-recognition
8
+ license: apache-2.0
9
+ widget:
10
+ - label: Sample 1 (from LibriSpeech)
11
+ src: https://cdn-media.huggingface.co/speech_samples/sample1.flac
12
+ ---
13
+
14
+ # Wav2Vec2-Base-TIMIT
15
+
16
+ Fine-tuned [facebook/wav2vec2-base](https://huggingface.co/facebook/wav2vec2-base)
17
+ on the [timit_asr dataset](https://huggingface.co/datasets/timit_asr).
18
+ When using this model, make sure that your speech input is sampled at 16kHz.
19
+
20
+ ## Usage
21
+
22
+ The model can be used directly (without a language model) as follows:
23
+
24
+ ```python
25
+ import torch
26
+ from datasets import load_dataset
27
+ import soundfile as sf
28
+ from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
29
+
30
+ model_name = "elgeish/wav2vec2-base-timit"
31
+ processor = Wav2Vec2Processor.from_pretrained(model_name, do_lower_case=True)
32
+ model = Wav2Vec2ForCTC.from_pretrained(model_name)
33
+ dataset = load_dataset("timit_asr", split="test[:10]")
34
+
35
+ def prepare_example(example):
36
+ example["speech"], _ = sf.read(example["file"])
37
+ return example
38
+
39
+ dataset = dataset.map(prepare_example, remove_columns=["file"])
40
+ inputs = processor(dataset["speech"], sampling_rate=16000, return_tensors="pt", padding="longest")
41
+
42
+ with torch.no_grad():
43
+ predicted_ids = torch.argmax(model(inputs.input_values).logits, dim=-1)
44
+ predicted_transcripts = processor.tokenizer.batch_decode(predicted_ids)
45
+ for reference, predicted in zip(dataset["text"], predicted_transcripts):
46
+ print("reference:", reference)
47
+ print("predicted:", predicted)
48
+ print("--")
49
+ ```
50
+
51
+ Here's the output:
52
+
53
+ ```
54
+ reference: The bungalow was pleasantly situated near the shore.
55
+ predicted: the bunglow was plesntly situated near the shor
56
+ --
57
+ reference: Don't ask me to carry an oily rag like that.
58
+ predicted: don't ask me to carry an oily rag like that
59
+ --
60
+ reference: Are you looking for employment?
61
+ predicted: are you oking for employment
62
+ --
63
+ reference: She had your dark suit in greasy wash water all year.
64
+ predicted: she had your dark suit in greasy wash water all year
65
+ --
66
+ reference: At twilight on the twelfth day we'll have Chablis.
67
+ predicted: at twilight on the twelfth day we'll have shiple
68
+ --
69
+ reference: Eating spinach nightly increases strength miraculously.
70
+ predicted: eating spanage nightly increases strength moraculously
71
+ --
72
+ reference: Got a heck of a buy on this, dirt cheap.
73
+ predicted: got a heck of a by on this dert cheep
74
+ --
75
+ reference: The scalloped edge is particularly appealing.
76
+ predicted: the scaliped edge iuse particularly appeling
77
+ --
78
+ reference: A big goat idly ambled through the farmyard.
79
+ predicted: a big goat idely ambled through the farmyard
80
+ --
81
+ reference: This group is secularist and their program tends to be technological.
82
+ predicted: this croup is secularist and their program tens to be technological
83
+ --
84
+ ```
85
+
86
+ ## Fine-Tuning Script
87
+
88
+ You can find the script used to produce this model
89
+ [here](https://github.com/elgeish/transformers/blob/f2b98f876b040bab3c3db8561ec39c1abb2c733c/examples/research_projects/wav2vec2/finetune_base_timit_asr.sh).
config.json ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "facebook/wav2vec2-base",
3
+ "activation_dropout": 0.0,
4
+ "apply_spec_augment": true,
5
+ "architectures": [
6
+ "Wav2Vec2ForCTC"
7
+ ],
8
+ "attention_dropout": 0.1,
9
+ "bos_token_id": 1,
10
+ "conv_bias": false,
11
+ "conv_dim": [
12
+ 512,
13
+ 512,
14
+ 512,
15
+ 512,
16
+ 512,
17
+ 512,
18
+ 512
19
+ ],
20
+ "conv_kernel": [
21
+ 10,
22
+ 3,
23
+ 3,
24
+ 3,
25
+ 3,
26
+ 2,
27
+ 2
28
+ ],
29
+ "conv_stride": [
30
+ 5,
31
+ 2,
32
+ 2,
33
+ 2,
34
+ 2,
35
+ 2,
36
+ 2
37
+ ],
38
+ "ctc_loss_reduction": "sum",
39
+ "ctc_zero_infinity": false,
40
+ "do_stable_layer_norm": false,
41
+ "eos_token_id": 2,
42
+ "feat_extract_activation": "gelu",
43
+ "feat_extract_norm": "group",
44
+ "feat_proj_dropout": 0.1,
45
+ "final_dropout": 0.0,
46
+ "freeze_feat_extract_train": true,
47
+ "gradient_checkpointing": true,
48
+ "hidden_act": "gelu",
49
+ "hidden_dropout": 0.1,
50
+ "hidden_size": 768,
51
+ "initializer_range": 0.02,
52
+ "intermediate_size": 3072,
53
+ "layer_norm_eps": 1e-05,
54
+ "layerdrop": 0.05,
55
+ "mask_channel_length": 10,
56
+ "mask_channel_min_space": 1,
57
+ "mask_channel_other": 0.0,
58
+ "mask_channel_prob": 0.0,
59
+ "mask_channel_selection": "static",
60
+ "mask_feature_length": 10,
61
+ "mask_feature_prob": 0.0,
62
+ "mask_time_length": 10,
63
+ "mask_time_min_space": 1,
64
+ "mask_time_other": 0.0,
65
+ "mask_time_prob": 0.05,
66
+ "mask_time_selection": "static",
67
+ "model_type": "wav2vec2",
68
+ "no_mask_channel_overlap": false,
69
+ "no_mask_time_overlap": false,
70
+ "num_attention_heads": 12,
71
+ "num_conv_pos_embedding_groups": 16,
72
+ "num_conv_pos_embeddings": 128,
73
+ "num_feat_extract_layers": 7,
74
+ "num_hidden_layers": 12,
75
+ "pad_token_id": 0,
76
+ "transformers_version": "4.4.0.dev0",
77
+ "vocab_size": 32
78
+ }
optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5ba21f66ab39aa0ef6701d053a58486d8212fcaf4c6f4b85d37041791d7a1188
3
+ size 721695047
preprocessor_config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_normalize": true,
3
+ "feature_size": 1,
4
+ "padding_side": "right",
5
+ "padding_value": 0.0,
6
+ "return_attention_mask": false,
7
+ "sampling_rate": 16000
8
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5203988324b278abe0d8fdcbc4cdf6b2e0a912e88ad03bbc5ee8fe964c6c2c0a
3
+ size 377675500
scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f56f4158e38f3499657e999614fc48915e802ced981e96a330bbaae50ad7d5e7
3
+ size 623
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
1
+ {"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "pad_token": "<pad>"}
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
1
+ {"unk_token": "<unk>", "bos_token": "<s>", "eos_token": "</s>", "pad_token": "<pad>", "do_lower_case": true, "word_delimiter_token": "|", "return_attention_mask": false, "do_normalize": true, "special_tokens_map_file": "special_tokens_map.json", "tokenizer_file": null, "name_or_path": "facebook/wav2vec2-base"}
trainer_state.json ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_metric": null,
3
+ "best_model_checkpoint": null,
4
+ "epoch": 17.24137931034483,
5
+ "global_step": 1000,
6
+ "is_hyper_param_search": false,
7
+ "is_local_process_zero": true,
8
+ "is_world_process_zero": true,
9
+ "log_history": [
10
+ {
11
+ "epoch": 0.86,
12
+ "learning_rate": 8.333333333333334e-06,
13
+ "loss": 8.2821,
14
+ "step": 50
15
+ },
16
+ {
17
+ "epoch": 1.72,
18
+ "learning_rate": 1.6666666666666667e-05,
19
+ "loss": 3.7831,
20
+ "step": 100
21
+ },
22
+ {
23
+ "epoch": 1.72,
24
+ "eval_loss": 6611.92333984375,
25
+ "eval_runtime": 118.2877,
26
+ "eval_samples_per_second": 14.203,
27
+ "eval_wer": 1.0,
28
+ "step": 100
29
+ },
30
+ {
31
+ "epoch": 2.59,
32
+ "learning_rate": 2.5e-05,
33
+ "loss": 3.15,
34
+ "step": 150
35
+ },
36
+ {
37
+ "epoch": 3.45,
38
+ "learning_rate": 3.3333333333333335e-05,
39
+ "loss": 3.0691,
40
+ "step": 200
41
+ },
42
+ {
43
+ "epoch": 3.45,
44
+ "eval_loss": 6203.90234375,
45
+ "eval_runtime": 117.1215,
46
+ "eval_samples_per_second": 14.344,
47
+ "eval_wer": 1.0,
48
+ "step": 200
49
+ },
50
+ {
51
+ "epoch": 4.31,
52
+ "learning_rate": 4.1666666666666665e-05,
53
+ "loss": 3.0065,
54
+ "step": 250
55
+ },
56
+ {
57
+ "epoch": 5.17,
58
+ "learning_rate": 5e-05,
59
+ "loss": 2.9693,
60
+ "step": 300
61
+ },
62
+ {
63
+ "epoch": 5.17,
64
+ "eval_loss": 5685.97509765625,
65
+ "eval_runtime": 116.8831,
66
+ "eval_samples_per_second": 14.373,
67
+ "eval_wer": 1.0,
68
+ "step": 300
69
+ },
70
+ {
71
+ "epoch": 6.03,
72
+ "learning_rate": 5.833333333333333e-05,
73
+ "loss": 2.9254,
74
+ "step": 350
75
+ },
76
+ {
77
+ "epoch": 6.9,
78
+ "learning_rate": 6.666666666666667e-05,
79
+ "loss": 2.4701,
80
+ "step": 400
81
+ },
82
+ {
83
+ "epoch": 6.9,
84
+ "eval_loss": 3466.919677734375,
85
+ "eval_runtime": 117.6489,
86
+ "eval_samples_per_second": 14.28,
87
+ "eval_wer": 0.975329851566795,
88
+ "step": 400
89
+ },
90
+ {
91
+ "epoch": 7.76,
92
+ "learning_rate": 7.5e-05,
93
+ "loss": 1.4256,
94
+ "step": 450
95
+ },
96
+ {
97
+ "epoch": 8.62,
98
+ "learning_rate": 8.333333333333333e-05,
99
+ "loss": 0.8495,
100
+ "step": 500
101
+ },
102
+ {
103
+ "epoch": 8.62,
104
+ "eval_loss": 1138.2066650390625,
105
+ "eval_runtime": 117.9419,
106
+ "eval_samples_per_second": 14.244,
107
+ "eval_wer": 0.44351291918636615,
108
+ "step": 500
109
+ },
110
+ {
111
+ "epoch": 9.48,
112
+ "learning_rate": 9.166666666666667e-05,
113
+ "loss": 0.5507,
114
+ "step": 550
115
+ },
116
+ {
117
+ "epoch": 10.34,
118
+ "learning_rate": 0.0001,
119
+ "loss": 0.466,
120
+ "step": 600
121
+ },
122
+ {
123
+ "epoch": 10.34,
124
+ "eval_loss": 1504.2208251953125,
125
+ "eval_runtime": 118.0119,
126
+ "eval_samples_per_second": 14.236,
127
+ "eval_wer": 0.4395959318306762,
128
+ "step": 600
129
+ },
130
+ {
131
+ "epoch": 11.21,
132
+ "learning_rate": 0.00010833333333333334,
133
+ "loss": 0.3447,
134
+ "step": 650
135
+ },
136
+ {
137
+ "epoch": 12.07,
138
+ "learning_rate": 0.00011666666666666667,
139
+ "loss": 0.3134,
140
+ "step": 700
141
+ },
142
+ {
143
+ "epoch": 12.07,
144
+ "eval_loss": 814.1062622070312,
145
+ "eval_runtime": 118.0128,
146
+ "eval_samples_per_second": 14.236,
147
+ "eval_wer": 0.30470038482682793,
148
+ "step": 700
149
+ },
150
+ {
151
+ "epoch": 12.93,
152
+ "learning_rate": 0.000125,
153
+ "loss": 0.2092,
154
+ "step": 750
155
+ },
156
+ {
157
+ "epoch": 13.79,
158
+ "learning_rate": 0.00013333333333333334,
159
+ "loss": 0.1698,
160
+ "step": 800
161
+ },
162
+ {
163
+ "epoch": 13.79,
164
+ "eval_loss": 785.0916137695312,
165
+ "eval_runtime": 117.6674,
166
+ "eval_samples_per_second": 14.278,
167
+ "eval_wer": 0.27762506871907644,
168
+ "step": 800
169
+ },
170
+ {
171
+ "epoch": 14.66,
172
+ "learning_rate": 0.00014166666666666668,
173
+ "loss": 0.1418,
174
+ "step": 850
175
+ },
176
+ {
177
+ "epoch": 15.52,
178
+ "learning_rate": 0.00015,
179
+ "loss": 0.1355,
180
+ "step": 900
181
+ },
182
+ {
183
+ "epoch": 15.52,
184
+ "eval_loss": 776.1622314453125,
185
+ "eval_runtime": 117.6741,
186
+ "eval_samples_per_second": 14.277,
187
+ "eval_wer": 0.25446673996701485,
188
+ "step": 900
189
+ },
190
+ {
191
+ "epoch": 16.38,
192
+ "learning_rate": 0.00015833333333333332,
193
+ "loss": 0.1799,
194
+ "step": 950
195
+ },
196
+ {
197
+ "epoch": 17.24,
198
+ "learning_rate": 0.00016666666666666666,
199
+ "loss": 0.1139,
200
+ "step": 1000
201
+ },
202
+ {
203
+ "epoch": 17.24,
204
+ "eval_loss": 801.2041015625,
205
+ "eval_runtime": 117.5787,
206
+ "eval_samples_per_second": 14.288,
207
+ "eval_wer": 0.24910665200659704,
208
+ "step": 1000
209
+ }
210
+ ],
211
+ "max_steps": 1740,
212
+ "num_train_epochs": 30,
213
+ "total_flos": 2.4339251400095805e+18,
214
+ "trial_name": null,
215
+ "trial_params": null
216
+ }
vocab.json ADDED
@@ -0,0 +1 @@
 
1
+ {"<pad>": 0, "<s>": 1, "</s>": 2, "<unk>": 3, "|": 4, "E": 5, "T": 6, "A": 7, "O": 8, "N": 9, "I": 10, "H": 11, "S": 12, "R": 13, "D": 14, "L": 15, "U": 16, "M": 17, "W": 18, "C": 19, "F": 20, "G": 21, "Y": 22, "P": 23, "B": 24, "V": 25, "K": 26, "'": 27, "X": 28, "J": 29, "Q": 30, "Z": 31}