acul3 commited on
Commit
4599a1d
1 Parent(s): b612b3d

first init

Browse files
README.md ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: id
3
+ datasets:
4
+ - common_voice
5
+ tags:
6
+ - speech
7
+ - audio
8
+ - automatic-speech-recognition
9
+ license: apache-2.0
10
+ ---
11
+ ## Evaluation on Common Voice NL Test
12
+ ```python
13
+ import torchaudio
14
+ from datasets import load_dataset, load_metric
15
+ from transformers import (
16
+ Wav2Vec2ForCTC,
17
+ Wav2Vec2Processor,
18
+ )
19
+ import torch
20
+ import re
21
+ import sys
22
+ model_name = "munggok/xlsr_indonesia"
23
+ device = "cuda"
24
+ chars_to_ignore_regex = '[\,\?\.\!\-\;\:\"]' # noqa: W605
25
+ model = Wav2Vec2ForCTC.from_pretrained(model_name).to(device)
26
+ processor = Wav2Vec2Processor.from_pretrained(model_name)
27
+ ds = load_dataset("common_voice", "nl", split="test", data_dir="./cv-corpus-6.1-2020-12-11")
28
+ resampler = torchaudio.transforms.Resample(orig_freq=48_000, new_freq=16_000)
29
+ def map_to_array(batch):
30
+ speech, _ = torchaudio.load(batch["path"])
31
+ batch["speech"] = resampler.forward(speech.squeeze(0)).numpy()
32
+ batch["sampling_rate"] = resampler.new_freq
33
+ batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower().replace("’", "'")
34
+ return batch
35
+ ds = ds.map(map_to_array)
36
+ def map_to_pred(batch):
37
+ features = processor(batch["speech"], sampling_rate=batch["sampling_rate"][0], padding=True, return_tensors="pt")
38
+ input_values = features.input_values.to(device)
39
+ attention_mask = features.attention_mask.to(device)
40
+ with torch.no_grad():
41
+ logits = model(input_values, attention_mask=attention_mask).logits
42
+ pred_ids = torch.argmax(logits, dim=-1)
43
+ batch["predicted"] = processor.batch_decode(pred_ids)
44
+ batch["target"] = batch["sentence"]
45
+ return batch
46
+ result = ds.map(map_to_pred, batched=True, batch_size=16, remove_columns=list(ds.features.keys()))
47
+ wer = load_metric("wer")
48
+ print(wer.compute(predictions=result["predicted"], references=result["target"]))
49
+ ```
50
+ **Result**: 25.7 %
config.json ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "facebook/wav2vec2-large-xlsr-53",
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": true,
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": "mean",
39
+ "ctc_zero_infinity": false,
40
+ "do_stable_layer_norm": true,
41
+ "eos_token_id": 2,
42
+ "feat_extract_activation": "gelu",
43
+ "feat_extract_dropout": 0.0,
44
+ "feat_extract_norm": "layer",
45
+ "feat_proj_dropout": 0.0,
46
+ "final_dropout": 0.0,
47
+ "gradient_checkpointing": true,
48
+ "hidden_act": "gelu",
49
+ "hidden_dropout": 0.1,
50
+ "hidden_size": 1024,
51
+ "initializer_range": 0.02,
52
+ "intermediate_size": 4096,
53
+ "layer_norm_eps": 1e-05,
54
+ "layerdrop": 0.1,
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
+ "num_attention_heads": 16,
69
+ "num_conv_pos_embedding_groups": 16,
70
+ "num_conv_pos_embeddings": 128,
71
+ "num_feat_extract_layers": 7,
72
+ "num_hidden_layers": 24,
73
+ "pad_token_id": 31,
74
+ "transformers_version": "4.4.0.dev0",
75
+ "vocab_size": 32
76
+ }
optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c67b8f3d154b6b27f24cd73d3d78bc0e0ef5eabeda9656f8fdadb3a8a3809b1
3
+ size 2490333205
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": true,
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:9d065f982130fb1eacb9da082e3b302a3b32e63e36aea272745181857aecb76c
3
+ size 1262060813
scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:24ef0b62cb8437196e7d6630866e06db9c28ac32a5ecf46fb1e8412c266225da
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": false, "word_delimiter_token": "|"}
trainer_state.json ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_metric": null,
3
+ "best_model_checkpoint": null,
4
+ "epoch": 58.064516129032256,
5
+ "global_step": 3600,
6
+ "is_hyper_param_search": false,
7
+ "is_local_process_zero": true,
8
+ "is_world_process_zero": true,
9
+ "log_history": [
10
+ {
11
+ "epoch": 9.68,
12
+ "learning_rate": 0.0002906832298136646,
13
+ "loss": 3.3346,
14
+ "step": 600
15
+ },
16
+ {
17
+ "epoch": 9.68,
18
+ "eval_loss": 0.4317544102668762,
19
+ "eval_runtime": 130.0321,
20
+ "eval_samples_per_second": 14.181,
21
+ "eval_wer": 0.5394368823419727,
22
+ "step": 600
23
+ },
24
+ {
25
+ "epoch": 19.35,
26
+ "learning_rate": 0.00023478260869565215,
27
+ "loss": 0.1371,
28
+ "step": 1200
29
+ },
30
+ {
31
+ "epoch": 19.35,
32
+ "eval_loss": 0.39734482765197754,
33
+ "eval_runtime": 130.3612,
34
+ "eval_samples_per_second": 14.145,
35
+ "eval_wer": 0.4464851762073466,
36
+ "step": 1200
37
+ },
38
+ {
39
+ "epoch": 29.03,
40
+ "learning_rate": 0.00017888198757763974,
41
+ "loss": 0.0616,
42
+ "step": 1800
43
+ },
44
+ {
45
+ "epoch": 29.03,
46
+ "eval_loss": 0.46754732728004456,
47
+ "eval_runtime": 132.7444,
48
+ "eval_samples_per_second": 13.891,
49
+ "eval_wer": 0.43147492075330973,
50
+ "step": 1800
51
+ },
52
+ {
53
+ "epoch": 38.71,
54
+ "learning_rate": 0.00012298136645962733,
55
+ "loss": 0.0415,
56
+ "step": 2400
57
+ },
58
+ {
59
+ "epoch": 38.71,
60
+ "eval_loss": 0.45845311880111694,
61
+ "eval_runtime": 133.8611,
62
+ "eval_samples_per_second": 13.775,
63
+ "eval_wer": 0.4201006899123625,
64
+ "step": 2400
65
+ },
66
+ {
67
+ "epoch": 48.39,
68
+ "learning_rate": 6.70807453416149e-05,
69
+ "loss": 0.0304,
70
+ "step": 3000
71
+ },
72
+ {
73
+ "epoch": 48.39,
74
+ "eval_loss": 0.47607213258743286,
75
+ "eval_runtime": 131.552,
76
+ "eval_samples_per_second": 14.017,
77
+ "eval_wer": 0.4080738392690658,
78
+ "step": 3000
79
+ },
80
+ {
81
+ "epoch": 58.06,
82
+ "learning_rate": 1.1180124223602484e-05,
83
+ "loss": 0.0244,
84
+ "step": 3600
85
+ },
86
+ {
87
+ "epoch": 58.06,
88
+ "eval_loss": 0.4667948782444,
89
+ "eval_runtime": 135.2111,
90
+ "eval_samples_per_second": 13.638,
91
+ "eval_wer": 0.40313257505127725,
92
+ "step": 3600
93
+ }
94
+ ],
95
+ "max_steps": 3720,
96
+ "num_train_epochs": 60,
97
+ "total_flos": 2.7090797391585608e+19,
98
+ "trial_name": null,
99
+ "trial_params": null
100
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:98bb98cc8415a567e93f2cc29652a031221c680373b22435b15d60af5c1b58a1
3
+ size 2287
vocab.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"e": 0, "w": 1, "y": 2, "v": 3, "z": 4, "\uff01": 5, "'": 6, "t": 7, "g": 8, "r": 9, "o": 11, "k": 12, "p": 13, "d": 14, "l": 15, "h": 16, "x": 17, "\u00e9": 18, "n": 19, "u": 20, "c": 21, "\uff0c": 22, "m": 23, "a": 24, "i": 25, "j": 26, "s": 27, "f": 28, "b": 29, "|": 10, "[UNK]": 30, "[PAD]": 31}