first commit
Browse files- README.md +122 -0
- config.json +116 -0
- preprocessor_config.json +10 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +6 -0
- tokenizer_config.json +11 -0
- vocab.json +34 -0
README.md
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: en
|
3 |
+
datasets:
|
4 |
+
- librispeech_asr
|
5 |
+
tags:
|
6 |
+
- audio
|
7 |
+
- automatic-speech-recognition
|
8 |
+
- hf-asr-leaderboard
|
9 |
+
widget:
|
10 |
+
- example_title: Librispeech sample 1
|
11 |
+
src: https://cdn-media.huggingface.co/speech_samples/sample1.flac
|
12 |
+
- example_title: Librispeech sample 2
|
13 |
+
src: https://cdn-media.huggingface.co/speech_samples/sample2.flac
|
14 |
+
model-index:
|
15 |
+
- name: ccc-wav2vec2-base-100h
|
16 |
+
results:
|
17 |
+
- task:
|
18 |
+
name: Automatic Speech Recognition
|
19 |
+
type: automatic-speech-recognition
|
20 |
+
dataset:
|
21 |
+
name: LibriSpeech (clean)
|
22 |
+
type: librispeech_asr
|
23 |
+
config: clean
|
24 |
+
split: test
|
25 |
+
args:
|
26 |
+
language: en
|
27 |
+
metrics:
|
28 |
+
- name: Test WER
|
29 |
+
type: wer
|
30 |
+
value: 5.5
|
31 |
+
- task:
|
32 |
+
name: Automatic Speech Recognition
|
33 |
+
type: automatic-speech-recognition
|
34 |
+
dataset:
|
35 |
+
name: LibriSpeech (other)
|
36 |
+
type: librispeech_asr
|
37 |
+
config: other
|
38 |
+
split: test
|
39 |
+
args:
|
40 |
+
language: en
|
41 |
+
metrics:
|
42 |
+
- name: Test WER
|
43 |
+
type: wer
|
44 |
+
value: 12.4
|
45 |
+
---
|
46 |
+
|
47 |
+
# ccc-Wav2Vec2-Base-100h
|
48 |
+
|
49 |
+
The base model pretrained on 960 hours of Librispeech and fine-tuned on 100 hours of Librispeech on 16kHz sampled speech audio. When using the model make sure that your speech input is also sampled at 16Khz.
|
50 |
+
|
51 |
+
[Paper](https://arxiv.org/abs/2210.02592)
|
52 |
+
|
53 |
+
Authors: Vasista Sai Lodagala, Sreyan Ghosh, S. Umesh
|
54 |
+
|
55 |
+
**Abstract**
|
56 |
+
While Self-Supervised Learning has helped reap the benefit of the scale from the available unlabeled data, the learning paradigms are continuously being bettered. We present a new pre-training strategy named ccc-wav2vec 2.0, which uses clustering and an augmentation-based cross-contrastive loss as its self-supervised objective. Through the clustering module, we scale down the influence of those negative examples that are highly similar to the positive. The Cross-Contrastive loss is computed between the encoder output of the original sample and the quantizer output of its augmentation and vice-versa, bringing robustness to the pre-training strategy. ccc-wav2vec 2.0 achieves up to 15.6% and 12.7% relative WER improvement over the baseline wav2vec 2.0 on the test-clean and test-other sets, respectively, of LibriSpeech, without the use of any language model. The proposed method also achieves up to 14.9% relative WER improvement over the baseline wav2vec 2.0 when fine-tuned on Switchboard data.
|
57 |
+
GitHub Page: https://github.com/speech-lab-iitm/ccc-wav2vec-2.0.
|
58 |
+
|
59 |
+
|
60 |
+
# Usage
|
61 |
+
|
62 |
+
To transcribe audio files the model can be used as a standalone acoustic model as follows:
|
63 |
+
|
64 |
+
```python
|
65 |
+
from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
|
66 |
+
from datasets import load_dataset
|
67 |
+
import torch
|
68 |
+
|
69 |
+
# load model and tokenizer
|
70 |
+
processor = Wav2Vec2Processor.from_pretrained("vasista22/ccc-wav2vec2-base-100h")
|
71 |
+
model = Wav2Vec2ForCTC.from_pretrained("vasista22/ccc-wav2vec2-base-100h")
|
72 |
+
|
73 |
+
# load dummy dataset and read soundfiles
|
74 |
+
ds = load_dataset("patrickvonplaten/librispeech_asr_dummy", "clean", split="validation")
|
75 |
+
|
76 |
+
# tokenize
|
77 |
+
input_values = processor(ds[0]["audio"]["array"], return_tensors="pt", padding="longest").input_values # Batch size 1
|
78 |
+
|
79 |
+
# retrieve logits
|
80 |
+
logits = model(input_values).logits
|
81 |
+
|
82 |
+
# take argmax and decode
|
83 |
+
predicted_ids = torch.argmax(logits, dim=-1)
|
84 |
+
transcription = processor.batch_decode(predicted_ids)
|
85 |
+
```
|
86 |
+
|
87 |
+
## Evaluation
|
88 |
+
|
89 |
+
This code snippet shows how to evaluate **vasista22/ccc-wav2vec2-base-100h** on LibriSpeech's "clean" and "other" test data.
|
90 |
+
|
91 |
+
```python
|
92 |
+
from datasets import load_dataset
|
93 |
+
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
|
94 |
+
import torch
|
95 |
+
from jiwer import wer
|
96 |
+
|
97 |
+
|
98 |
+
librispeech_eval = load_dataset("librispeech_asr", "clean", split="test")
|
99 |
+
|
100 |
+
model = Wav2Vec2ForCTC.from_pretrained("vasista22/ccc-wav2vec2-base-100h").to("cuda")
|
101 |
+
processor = Wav2Vec2Processor.from_pretrained("vasista22/ccc-wav2vec2-base-100h")
|
102 |
+
|
103 |
+
def map_to_pred(batch):
|
104 |
+
input_values = processor(batch["audio"]["array"], return_tensors="pt", padding="longest").input_values
|
105 |
+
with torch.no_grad():
|
106 |
+
logits = model(input_values.to("cuda")).logits
|
107 |
+
|
108 |
+
predicted_ids = torch.argmax(logits, dim=-1)
|
109 |
+
transcription = processor.batch_decode(predicted_ids)
|
110 |
+
batch["transcription"] = transcription
|
111 |
+
return batch
|
112 |
+
|
113 |
+
result = librispeech_eval.map(map_to_pred, batched=True, batch_size=1, remove_columns=["audio"])
|
114 |
+
|
115 |
+
print("WER:", wer(result["text"], result["transcription"]))
|
116 |
+
```
|
117 |
+
|
118 |
+
*Result (WER)*:
|
119 |
+
|
120 |
+
| "clean" | "other" |
|
121 |
+
|---|---|
|
122 |
+
| 5.5 | 12.4 |
|
config.json
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"activation_dropout": 0.0,
|
3 |
+
"adapter_kernel_size": 3,
|
4 |
+
"adapter_stride": 2,
|
5 |
+
"add_adapter": false,
|
6 |
+
"apply_spec_augment": true,
|
7 |
+
"architectures": [
|
8 |
+
"Wav2Vec2ForCTC"
|
9 |
+
],
|
10 |
+
"attention_dropout": 0.1,
|
11 |
+
"bos_token_id": 1,
|
12 |
+
"classifier_proj_size": 256,
|
13 |
+
"codevector_dim": 256,
|
14 |
+
"contrastive_logits_temperature": 0.1,
|
15 |
+
"conv_bias": false,
|
16 |
+
"conv_dim": [
|
17 |
+
512,
|
18 |
+
512,
|
19 |
+
512,
|
20 |
+
512,
|
21 |
+
512,
|
22 |
+
512,
|
23 |
+
512
|
24 |
+
],
|
25 |
+
"conv_kernel": [
|
26 |
+
10,
|
27 |
+
3,
|
28 |
+
3,
|
29 |
+
3,
|
30 |
+
3,
|
31 |
+
2,
|
32 |
+
2
|
33 |
+
],
|
34 |
+
"conv_stride": [
|
35 |
+
5,
|
36 |
+
2,
|
37 |
+
2,
|
38 |
+
2,
|
39 |
+
2,
|
40 |
+
2,
|
41 |
+
2
|
42 |
+
],
|
43 |
+
"ctc_loss_reduction": "sum",
|
44 |
+
"ctc_zero_infinity": false,
|
45 |
+
"diversity_loss_weight": 0.1,
|
46 |
+
"do_stable_layer_norm": false,
|
47 |
+
"eos_token_id": 2,
|
48 |
+
"feat_extract_activation": "gelu",
|
49 |
+
"feat_extract_norm": "group",
|
50 |
+
"feat_proj_dropout": 0.1,
|
51 |
+
"feat_quantizer_dropout": 0.0,
|
52 |
+
"final_dropout": 0.0,
|
53 |
+
"freeze_feat_extract_train": true,
|
54 |
+
"hidden_act": "gelu",
|
55 |
+
"hidden_dropout": 0.1,
|
56 |
+
"hidden_size": 768,
|
57 |
+
"initializer_range": 0.02,
|
58 |
+
"intermediate_size": 3072,
|
59 |
+
"layer_norm_eps": 1e-05,
|
60 |
+
"layerdrop": 0.0,
|
61 |
+
"mask_channel_length": 10,
|
62 |
+
"mask_channel_min_space": 1,
|
63 |
+
"mask_channel_other": 0.0,
|
64 |
+
"mask_channel_prob": 0.0,
|
65 |
+
"mask_channel_selection": "static",
|
66 |
+
"mask_feature_length": 10,
|
67 |
+
"mask_feature_min_masks": 0,
|
68 |
+
"mask_feature_prob": 0.0,
|
69 |
+
"mask_time_length": 10,
|
70 |
+
"mask_time_min_masks": 2,
|
71 |
+
"mask_time_min_space": 1,
|
72 |
+
"mask_time_other": 0.0,
|
73 |
+
"mask_time_prob": 0.05,
|
74 |
+
"mask_time_selection": "static",
|
75 |
+
"model_type": "wav2vec2",
|
76 |
+
"no_mask_channel_overlap": false,
|
77 |
+
"no_mask_time_overlap": false,
|
78 |
+
"num_adapter_layers": 3,
|
79 |
+
"num_attention_heads": 12,
|
80 |
+
"num_codevector_groups": 2,
|
81 |
+
"num_codevectors_per_group": 320,
|
82 |
+
"num_conv_pos_embedding_groups": 16,
|
83 |
+
"num_conv_pos_embeddings": 128,
|
84 |
+
"num_feat_extract_layers": 7,
|
85 |
+
"num_hidden_layers": 12,
|
86 |
+
"num_negatives": 100,
|
87 |
+
"output_hidden_size": 768,
|
88 |
+
"pad_token_id": 0,
|
89 |
+
"proj_codevector_dim": 256,
|
90 |
+
"tdnn_dilation": [
|
91 |
+
1,
|
92 |
+
2,
|
93 |
+
3,
|
94 |
+
1,
|
95 |
+
1
|
96 |
+
],
|
97 |
+
"tdnn_dim": [
|
98 |
+
512,
|
99 |
+
512,
|
100 |
+
512,
|
101 |
+
512,
|
102 |
+
1500
|
103 |
+
],
|
104 |
+
"tdnn_kernel": [
|
105 |
+
5,
|
106 |
+
3,
|
107 |
+
3,
|
108 |
+
1,
|
109 |
+
1
|
110 |
+
],
|
111 |
+
"torch_dtype": "float32",
|
112 |
+
"transformers_version": "4.24.0",
|
113 |
+
"use_weighted_layer_sum": false,
|
114 |
+
"vocab_size": 32,
|
115 |
+
"xvector_output_dim": 512
|
116 |
+
}
|
preprocessor_config.json
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"do_normalize": true,
|
3 |
+
"feature_extractor_type": "Wav2Vec2FeatureExtractor",
|
4 |
+
"feature_size": 1,
|
5 |
+
"padding_side": "right",
|
6 |
+
"padding_value": 0,
|
7 |
+
"processor_class": "Wav2Vec2Processor",
|
8 |
+
"return_attention_mask": false,
|
9 |
+
"sampling_rate": 16000
|
10 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4c0826505d19b62308a468122cb4a4a43561c2f7f68deb780264173282add2d8
|
3 |
+
size 377653911
|
special_tokens_map.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"eos_token": "</s>",
|
4 |
+
"pad_token": "<pad>",
|
5 |
+
"unk_token": "<unk>"
|
6 |
+
}
|
tokenizer_config.json
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"do_lower_case": false,
|
4 |
+
"eos_token": "</s>",
|
5 |
+
"pad_token": "<pad>",
|
6 |
+
"processor_class": "Wav2Vec2Processor",
|
7 |
+
"replace_word_delimiter_char": " ",
|
8 |
+
"tokenizer_class": "Wav2Vec2CTCTokenizer",
|
9 |
+
"unk_token": "<unk>",
|
10 |
+
"word_delimiter_token": "|"
|
11 |
+
}
|
vocab.json
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"'": 27,
|
3 |
+
"</s>": 2,
|
4 |
+
"<pad>": 0,
|
5 |
+
"<s>": 1,
|
6 |
+
"<unk>": 3,
|
7 |
+
"A": 7,
|
8 |
+
"B": 24,
|
9 |
+
"C": 19,
|
10 |
+
"D": 14,
|
11 |
+
"E": 5,
|
12 |
+
"F": 20,
|
13 |
+
"G": 21,
|
14 |
+
"H": 11,
|
15 |
+
"I": 10,
|
16 |
+
"J": 29,
|
17 |
+
"K": 26,
|
18 |
+
"L": 15,
|
19 |
+
"M": 17,
|
20 |
+
"N": 9,
|
21 |
+
"O": 8,
|
22 |
+
"P": 23,
|
23 |
+
"Q": 30,
|
24 |
+
"R": 13,
|
25 |
+
"S": 12,
|
26 |
+
"T": 6,
|
27 |
+
"U": 16,
|
28 |
+
"V": 25,
|
29 |
+
"W": 18,
|
30 |
+
"X": 28,
|
31 |
+
"Y": 22,
|
32 |
+
"Z": 31,
|
33 |
+
"|": 4
|
34 |
+
}
|