add files
Browse files- README.md +120 -0
- config.json +46 -0
- preprocessor_config.json +11 -0
- pytorch_model.bin +3 -0
- sentencepiece.bpe.model +3 -0
- special_tokens_map.json +1 -0
- tokenizer_config.json +1 -0
- vocab.json +189 -0
README.md
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- es
|
4 |
+
- en
|
5 |
+
datasets:
|
6 |
+
- covost2
|
7 |
+
tags:
|
8 |
+
- audio
|
9 |
+
- speech-translation
|
10 |
+
- automatic-speech-recognition
|
11 |
+
license: MIT
|
12 |
+
---
|
13 |
+
|
14 |
+
|
15 |
+
# S2T-SMALL-COVOST2-ES-EN-ST
|
16 |
+
|
17 |
+
`s2t-small-covost2-es-en-st` is a Speech to Text Transformer (S2T) model trained for end-to-end Speech Translation (ST).
|
18 |
+
The S2T model was proposed in [this paper](https://arxiv.org/abs/2010.05171) and released in
|
19 |
+
[this repository](https://github.com/pytorch/fairseq/tree/master/examples/speech_to_text)
|
20 |
+
|
21 |
+
|
22 |
+
## Model description
|
23 |
+
|
24 |
+
S2T is a transformer-based seq2seq (encoder-decoder) model designed for end-to-end Automatic Speech Recognition (ASR) and Speech
|
25 |
+
Translation (ST). It uses a convolutional downsampler to reduce the length of speech inputs by 3/4th before they are
|
26 |
+
fed into the encoder. The model is trained with standard autoregressive cross-entropy loss and generates the
|
27 |
+
transcripts/translations autoregressively.
|
28 |
+
|
29 |
+
## Intended uses & limitations
|
30 |
+
|
31 |
+
This model can be used for end-to-end Spanish speech to English text translation.
|
32 |
+
See the [model hub](https://huggingface.co/models?filter=speech_to_text) to look for other S2T checkpoints.
|
33 |
+
|
34 |
+
|
35 |
+
### How to use
|
36 |
+
|
37 |
+
As this a standard sequence to sequence transformer model, you can use the `generate` method to generate the
|
38 |
+
transcripts by passing the speech features to the model.
|
39 |
+
|
40 |
+
*Note: The `Speech2TextProcessor` object uses [torchaudio](https://github.com/pytorch/audio) to extract the
|
41 |
+
filter bank features. Make sure to install the `torchaudio` package before running this example.*
|
42 |
+
|
43 |
+
You could either install those as extra speech dependancies with
|
44 |
+
`pip install transformers"[speech, sentencepiece]"` or install the packages seperatly
|
45 |
+
with `pip install torchaudio sentencepiece`.
|
46 |
+
|
47 |
+
|
48 |
+
```python
|
49 |
+
import torch
|
50 |
+
from transformers import Speech2TextProcessor, Speech2TextForConditionalGeneration
|
51 |
+
from datasets import load_dataset
|
52 |
+
import soundfile as sf
|
53 |
+
|
54 |
+
model = Speech2TextForConditionalGeneration.from_pretrained("facebook/s2t-small-covost2-es-en-st")
|
55 |
+
processor = Speech2TextProcessor.from_pretrained("facebook/s2t-small-covost2-es-en-st")
|
56 |
+
|
57 |
+
def map_to_array(batch):
|
58 |
+
speech, _ = sf.read(batch["file"])
|
59 |
+
batch["speech"] = speech
|
60 |
+
return batch
|
61 |
+
|
62 |
+
ds = load_dataset(
|
63 |
+
"patrickvonplaten/librispeech_asr_dummy",
|
64 |
+
"clean",
|
65 |
+
split="validation"
|
66 |
+
)
|
67 |
+
ds = ds.map(map_to_array)
|
68 |
+
|
69 |
+
inputs = processor(
|
70 |
+
ds["speech"][0],
|
71 |
+
sampling_rate=48_000,
|
72 |
+
return_tensors="pt"
|
73 |
+
)
|
74 |
+
generated_ids = model.generate(input_ids=inputs["input_features"], attention_mask=inputs["attention_mask"])
|
75 |
+
|
76 |
+
translation = processor.batch_decode(generated_ids, skip_special_tokens=True)
|
77 |
+
```
|
78 |
+
|
79 |
+
|
80 |
+
## Training data
|
81 |
+
|
82 |
+
The s2t-small-covost2-es-en-st is trained on Spanish-English subset of [CoVoST2](https://github.com/facebookresearch/covost).
|
83 |
+
CoVoST is a large-scale multilingual ST corpus based on [Common Voice](https://arxiv.org/abs/1912.06670), created to to foster
|
84 |
+
ST research with the largest ever open dataset
|
85 |
+
|
86 |
+
|
87 |
+
## Training procedure
|
88 |
+
|
89 |
+
### Preprocessing
|
90 |
+
|
91 |
+
The speech data is pre-processed by extracting Kaldi-compliant 80-channel log mel-filter bank features automatically from
|
92 |
+
WAV/FLAC audio files via PyKaldi or torchaudio. Further utterance-level CMVN (cepstral mean and variance normalization)
|
93 |
+
is applied to each example.
|
94 |
+
|
95 |
+
The texts are lowercased and tokenized using character based SentencePiece vocab.
|
96 |
+
|
97 |
+
|
98 |
+
### Training
|
99 |
+
|
100 |
+
The model is trained with standard autoregressive cross-entropy loss and using [SpecAugment](https://arxiv.org/abs/1904.08779).
|
101 |
+
The encoder receives speech features, and the decoder generates the transcripts autoregressively. To accelerate
|
102 |
+
model training and for better performance the encoder is pre-trained for English ASR.
|
103 |
+
|
104 |
+
## Evaluation results
|
105 |
+
|
106 |
+
CoVOST2 test results for es-en (BLEU score): 22.31
|
107 |
+
|
108 |
+
|
109 |
+
|
110 |
+
### BibTeX entry and citation info
|
111 |
+
|
112 |
+
```bibtex
|
113 |
+
@inproceedings{wang2020fairseqs2t,
|
114 |
+
title = {fairseq S2T: Fast Speech-to-Text Modeling with fairseq},
|
115 |
+
author = {Changhan Wang and Yun Tang and Xutai Ma and Anne Wu and Dmytro Okhonko and Juan Pino},
|
116 |
+
booktitle = {Proceedings of the 2020 Conference of the Asian Chapter of the Association for Computational Linguistics (AACL): System Demonstrations},
|
117 |
+
year = {2020},
|
118 |
+
}
|
119 |
+
|
120 |
+
```
|
config.json
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"activation_dropout": 0.1,
|
3 |
+
"activation_function": "relu",
|
4 |
+
"architectures": [
|
5 |
+
"Speech2TextForConditionalGeneration"
|
6 |
+
],
|
7 |
+
"attention_dropout": 0.1,
|
8 |
+
"bos_token_id": 0,
|
9 |
+
"classifier_dropout": 0.0,
|
10 |
+
"conv_channels": 1024,
|
11 |
+
"conv_kernel_sizes": [
|
12 |
+
5,
|
13 |
+
5
|
14 |
+
],
|
15 |
+
"d_model": 256,
|
16 |
+
"decoder_attention_heads": 4,
|
17 |
+
"decoder_ffn_dim": 2048,
|
18 |
+
"decoder_layerdrop": 0.0,
|
19 |
+
"decoder_layers": 6,
|
20 |
+
"decoder_start_token_id": 2,
|
21 |
+
"dropout": 0.1,
|
22 |
+
"early_stopping": true,
|
23 |
+
"encoder_attention_heads": 4,
|
24 |
+
"encoder_ffn_dim": 2048,
|
25 |
+
"encoder_layerdrop": 0.0,
|
26 |
+
"encoder_layers": 12,
|
27 |
+
"eos_token_id": 2,
|
28 |
+
"gradient_checkpointing": false,
|
29 |
+
"init_std": 0.02,
|
30 |
+
"input_channels": 1,
|
31 |
+
"input_feat_per_channel": 80,
|
32 |
+
"is_encoder_decoder": true,
|
33 |
+
"max_length": 200,
|
34 |
+
"max_source_positions": 6000,
|
35 |
+
"max_target_positions": 1024,
|
36 |
+
"model_type": "speech_to_text",
|
37 |
+
"num_beams": 5,
|
38 |
+
"num_conv_layers": 2,
|
39 |
+
"num_hidden_layers": 12,
|
40 |
+
"pad_token_id": 1,
|
41 |
+
"scale_embedding": true,
|
42 |
+
"tie_word_embeddings": false,
|
43 |
+
"transformers_version": "4.4.0.dev0",
|
44 |
+
"use_cache": true,
|
45 |
+
"vocab_size": 187
|
46 |
+
}
|
preprocessor_config.json
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"do_ceptral_normalize": true,
|
3 |
+
"feature_size": 80,
|
4 |
+
"normalize_means": true,
|
5 |
+
"normalize_vars": true,
|
6 |
+
"num_mel_bins": 80,
|
7 |
+
"padding_side": "right",
|
8 |
+
"padding_value": 0.0,
|
9 |
+
"return_attention_mask": true,
|
10 |
+
"sampling_rate": 48000
|
11 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:118c198454db94a4a44622582bcd6b9fc5a0cdd26bf7f6fa019e95db76b258f7
|
3 |
+
size 108410373
|
sentencepiece.bpe.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8f8d2e8d81cb7c1d505abd56e5f3cc59c580eb20bf94c519b3142700d892a524
|
3 |
+
size 239715
|
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 |
+
{"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "pad_token": "<pad>", "do_upper_case": false, "do_lower_case": false, "tgt_lang": null, "lang_codes": null, "tokenizer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 13,
|
16 |
+
"l": 14,
|
17 |
+
"d": 15,
|
18 |
+
"c": 16,
|
19 |
+
"u": 17,
|
20 |
+
"m": 18,
|
21 |
+
".": 19,
|
22 |
+
"f": 20,
|
23 |
+
"p": 21,
|
24 |
+
"y": 22,
|
25 |
+
"g": 23,
|
26 |
+
"w": 24,
|
27 |
+
"b": 25,
|
28 |
+
"v": 26,
|
29 |
+
",": 27,
|
30 |
+
"T": 28,
|
31 |
+
"k": 29,
|
32 |
+
"I": 30,
|
33 |
+
"A": 31,
|
34 |
+
"H": 32,
|
35 |
+
"S": 33,
|
36 |
+
"C": 34,
|
37 |
+
"M": 35,
|
38 |
+
"\u2019": 36,
|
39 |
+
"B": 37,
|
40 |
+
"x": 38,
|
41 |
+
"P": 39,
|
42 |
+
"z": 40,
|
43 |
+
"W": 41,
|
44 |
+
"L": 42,
|
45 |
+
"F": 43,
|
46 |
+
"D": 44,
|
47 |
+
"R": 45,
|
48 |
+
"G": 46,
|
49 |
+
"E": 47,
|
50 |
+
"N": 48,
|
51 |
+
"j": 49,
|
52 |
+
"O": 50,
|
53 |
+
"-": 51,
|
54 |
+
"q": 52,
|
55 |
+
"!": 53,
|
56 |
+
"\u201d": 54,
|
57 |
+
"\u201c": 55,
|
58 |
+
"J": 56,
|
59 |
+
"?": 57,
|
60 |
+
"V": 58,
|
61 |
+
"U": 59,
|
62 |
+
"'": 60,
|
63 |
+
"\"": 61,
|
64 |
+
"Y": 62,
|
65 |
+
":": 63,
|
66 |
+
"K": 64,
|
67 |
+
"\u00ed": 65,
|
68 |
+
"\u00e1": 66,
|
69 |
+
"\u00f3": 67,
|
70 |
+
"\u00f1": 68,
|
71 |
+
"Z": 69,
|
72 |
+
"\u0301": 70,
|
73 |
+
"Q": 71,
|
74 |
+
"/": 72,
|
75 |
+
";": 73,
|
76 |
+
"\u2018": 74,
|
77 |
+
"\u00fa": 75,
|
78 |
+
"\u00e9": 76,
|
79 |
+
"0": 77,
|
80 |
+
"\u00c1": 78,
|
81 |
+
"X": 79,
|
82 |
+
"1": 80,
|
83 |
+
"\u00fc": 81,
|
84 |
+
"2": 82,
|
85 |
+
"4": 83,
|
86 |
+
"\u00e3": 84,
|
87 |
+
"\u00f6": 85,
|
88 |
+
"(": 86,
|
89 |
+
")": 87,
|
90 |
+
"8": 88,
|
91 |
+
"\u2013": 89,
|
92 |
+
"5": 90,
|
93 |
+
"%": 91,
|
94 |
+
"3": 92,
|
95 |
+
"\u00e2": 93,
|
96 |
+
"\u00e7": 94,
|
97 |
+
"\u00e4": 95,
|
98 |
+
"\u014d": 96,
|
99 |
+
"\u00eb": 97,
|
100 |
+
"\u00a1": 98,
|
101 |
+
"\u00d3": 99,
|
102 |
+
"\u00c9": 100,
|
103 |
+
"9": 101,
|
104 |
+
"\u0101": 102,
|
105 |
+
"7": 103,
|
106 |
+
"\u00da": 104,
|
107 |
+
"\u00f4": 105,
|
108 |
+
"6": 106,
|
109 |
+
"`": 107,
|
110 |
+
"\u00bf": 108,
|
111 |
+
"\u00f8": 109,
|
112 |
+
"*": 110,
|
113 |
+
"[": 111,
|
114 |
+
"]": 112,
|
115 |
+
"\u00e6": 113,
|
116 |
+
"\u00ea": 114,
|
117 |
+
"\u0308": 115,
|
118 |
+
"\u2014": 116,
|
119 |
+
"&": 117,
|
120 |
+
"\u00c0": 118,
|
121 |
+
"\u00ef": 119,
|
122 |
+
"\u0107": 120,
|
123 |
+
"\u0161": 121,
|
124 |
+
"\u016b": 122,
|
125 |
+
"\u02bb": 123,
|
126 |
+
"\u00b0": 124,
|
127 |
+
"\u00d1": 125,
|
128 |
+
"\u00df": 126,
|
129 |
+
"\u00fd": 127,
|
130 |
+
"\u010c": 128,
|
131 |
+
"\u010d": 129,
|
132 |
+
"\u0111": 130,
|
133 |
+
"\u0117": 131,
|
134 |
+
"\u012b": 132,
|
135 |
+
"\u0160": 133,
|
136 |
+
"\u0451": 134,
|
137 |
+
"\u2015": 135,
|
138 |
+
"\u30b4": 136,
|
139 |
+
"#": 137,
|
140 |
+
"<": 138,
|
141 |
+
"=": 139,
|
142 |
+
">": 140,
|
143 |
+
"\u00b7": 141,
|
144 |
+
"\u00c4": 142,
|
145 |
+
"\u00c6": 143,
|
146 |
+
"\u00d0": 144,
|
147 |
+
"\u00d6": 145,
|
148 |
+
"\u00de": 146,
|
149 |
+
"\u00f0": 147,
|
150 |
+
"\u00f9": 148,
|
151 |
+
"\u00fb": 149,
|
152 |
+
"\u0103": 150,
|
153 |
+
"\u011b": 151,
|
154 |
+
"\u0130": 152,
|
155 |
+
"\u0131": 153,
|
156 |
+
"\u0142": 154,
|
157 |
+
"\u0144": 155,
|
158 |
+
"\u0153": 156,
|
159 |
+
"\u0159": 157,
|
160 |
+
"\u015a": 158,
|
161 |
+
"\u015e": 159,
|
162 |
+
"\u017e": 160,
|
163 |
+
"\u021b": 161,
|
164 |
+
"\u0259": 162,
|
165 |
+
"\u02bf": 163,
|
166 |
+
"\u03d8": 164,
|
167 |
+
"\u05d4": 165,
|
168 |
+
"\u05d9": 166,
|
169 |
+
"\u05db": 167,
|
170 |
+
"\u05e0": 168,
|
171 |
+
"\u05e9": 169,
|
172 |
+
"\u0628": 170,
|
173 |
+
"\u0629": 171,
|
174 |
+
"\u0630": 172,
|
175 |
+
"\u0647": 173,
|
176 |
+
"\u064a": 174,
|
177 |
+
"\u1e43": 175,
|
178 |
+
"\u2027": 176,
|
179 |
+
"\u2039": 177,
|
180 |
+
"\u203a": 178,
|
181 |
+
"\u3057": 179,
|
182 |
+
"\u306e": 180,
|
183 |
+
"\u30df": 181,
|
184 |
+
"\u30e0": 182,
|
185 |
+
"\u6d88": 183,
|
186 |
+
"\u7bb1": 184,
|
187 |
+
"\u9b93": 185,
|
188 |
+
"\u9ba8": 186
|
189 |
+
}
|