Dupaja Matthijs commited on
Commit
4953638
0 Parent(s):

Duplicate from microsoft/speecht5_tts

Browse files

Co-authored-by: Mathijs Hollemans <Matthijs@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel 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
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - audio
5
+ - text-to-speech
6
+ datasets:
7
+ - libritts
8
+ ---
9
+
10
+ # SpeechT5 (TTS task)
11
+
12
+ SpeechT5 model fine-tuned for speech synthesis (text-to-speech) on LibriTTS.
13
+
14
+ This model was introduced in [SpeechT5: Unified-Modal Encoder-Decoder Pre-Training for Spoken Language Processing](https://arxiv.org/abs/2110.07205) by Junyi Ao, Rui Wang, Long Zhou, Chengyi Wang, Shuo Ren, Yu Wu, Shujie Liu, Tom Ko, Qing Li, Yu Zhang, Zhihua Wei, Yao Qian, Jinyu Li, Furu Wei.
15
+
16
+ SpeechT5 was first released in [this repository](https://github.com/microsoft/SpeechT5/), [original weights](https://huggingface.co/mechanicalsea/speecht5-tts). The license used is [MIT](https://github.com/microsoft/SpeechT5/blob/main/LICENSE).
17
+
18
+
19
+
20
+ ## Model Description
21
+
22
+ Motivated by the success of T5 (Text-To-Text Transfer Transformer) in pre-trained natural language processing models, we propose a unified-modal SpeechT5 framework that explores the encoder-decoder pre-training for self-supervised speech/text representation learning. The SpeechT5 framework consists of a shared encoder-decoder network and six modal-specific (speech/text) pre/post-nets. After preprocessing the input speech/text through the pre-nets, the shared encoder-decoder network models the sequence-to-sequence transformation, and then the post-nets generate the output in the speech/text modality based on the output of the decoder.
23
+
24
+ Leveraging large-scale unlabeled speech and text data, we pre-train SpeechT5 to learn a unified-modal representation, hoping to improve the modeling capability for both speech and text. To align the textual and speech information into this unified semantic space, we propose a cross-modal vector quantization approach that randomly mixes up speech/text states with latent units as the interface between encoder and decoder.
25
+
26
+ Extensive evaluations show the superiority of the proposed SpeechT5 framework on a wide variety of spoken language processing tasks, including automatic speech recognition, speech synthesis, speech translation, voice conversion, speech enhancement, and speaker identification.
27
+
28
+ - **Developed by:** Junyi Ao, Rui Wang, Long Zhou, Chengyi Wang, Shuo Ren, Yu Wu, Shujie Liu, Tom Ko, Qing Li, Yu Zhang, Zhihua Wei, Yao Qian, Jinyu Li, Furu Wei.
29
+ - **Shared by [optional]:** [Matthijs Hollemans](https://huggingface.co/Matthijs)
30
+ - **Model type:** text-to-speech
31
+ - **Language(s) (NLP):** [More Information Needed]
32
+ - **License:** [MIT](https://github.com/microsoft/SpeechT5/blob/main/LICENSE)
33
+ - **Finetuned from model [optional]:** [More Information Needed]
34
+
35
+
36
+ ## Model Sources [optional]
37
+
38
+ <!-- Provide the basic links for the model. -->
39
+
40
+ - **Repository:** [https://github.com/microsoft/SpeechT5/]
41
+ - **Paper:** [https://arxiv.org/pdf/2110.07205.pdf]
42
+ - **Blog Post:** [https://huggingface.co/blog/speecht5]
43
+ - **Demo:** [https://huggingface.co/spaces/Matthijs/speecht5-tts-demo]
44
+
45
+
46
+ # Uses
47
+
48
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
49
+
50
+ ## 🤗 Transformers Usage
51
+
52
+ You can run SpeechT5 TTS locally with the 🤗 Transformers library.
53
+
54
+ 1. First install the 🤗 [Transformers library](https://github.com/huggingface/transformers), sentencepiece, soundfile and datasets(optional):
55
+
56
+ ```
57
+ pip install --upgrade pip
58
+ pip install --upgrade transformers sentencepiece datasets[audio]
59
+ ```
60
+
61
+ 2. Run inference via the `Text-to-Speech` (TTS) pipeline. You can access the SpeechT5 model via the TTS pipeline in just a few lines of code!
62
+
63
+ ```python
64
+ from transformers import pipeline
65
+ from datasets import load_dataset
66
+ import soundfile as sf
67
+
68
+ synthesiser = pipeline("text-to-speech", "microsoft/speecht5_tts")
69
+
70
+ embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
71
+ speaker_embedding = torch.tensor(embeddings_dataset[7306]["xvector"]).unsqueeze(0)
72
+ # You can replace this embedding with your own as well.
73
+
74
+ speech = synthesiser("Hello, my dog is cooler than you!", forward_params={"speaker_embeddings": speaker_embedding})
75
+
76
+ sf.write("speech.wav", speech["audio"], samplerate=speech["sampling_rate"])
77
+ ```
78
+
79
+ 3. Run inference via the Transformers modelling code - You can use the processor + generate code to convert text into a mono 16 kHz speech waveform for more fine-grained control.
80
+
81
+ ```python
82
+ from transformers import SpeechT5Processor, SpeechT5ForTextToSpeech, SpeechT5HifiGan
83
+ from datasets import load_dataset
84
+ import torch
85
+ import soundfile as sf
86
+ from datasets import load_dataset
87
+
88
+ processor = SpeechT5Processor.from_pretrained("microsoft/speecht5_tts")
89
+ model = SpeechT5ForTextToSpeech.from_pretrained("microsoft/speecht5_tts")
90
+ vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan")
91
+
92
+ inputs = processor(text="Hello, my dog is cute.", return_tensors="pt")
93
+
94
+ # load xvector containing speaker's voice characteristics from a dataset
95
+ embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
96
+ speaker_embeddings = torch.tensor(embeddings_dataset[7306]["xvector"]).unsqueeze(0)
97
+
98
+ speech = model.generate_speech(inputs["input_ids"], speaker_embeddings, vocoder=vocoder)
99
+
100
+ sf.write("speech.wav", speech.numpy(), samplerate=16000)
101
+ ```
102
+
103
+ ### Fine-tuning the Model
104
+
105
+ Refer to [this Colab notebook](https://colab.research.google.com/drive/1i7I5pzBcU3WDFarDnzweIj4-sVVoIUFJ) for an example of how to fine-tune SpeechT5 for TTS on a different dataset or a new language.
106
+
107
+
108
+ ## Direct Use
109
+
110
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
111
+
112
+ You can use this model for speech synthesis. See the [model hub](https://huggingface.co/models?search=speecht5) to look for fine-tuned versions on a task that interests you.
113
+
114
+ ## Downstream Use [optional]
115
+
116
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
117
+
118
+ [More Information Needed]
119
+
120
+ ## Out-of-Scope Use
121
+
122
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
123
+
124
+ [More Information Needed]
125
+
126
+ # Bias, Risks, and Limitations
127
+
128
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
129
+
130
+ [More Information Needed]
131
+
132
+ ## Recommendations
133
+
134
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
135
+
136
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
137
+
138
+ # Training Details
139
+
140
+ ## Training Data
141
+
142
+ <!-- This should link to a Data Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
143
+
144
+ LibriTTS
145
+
146
+ ## Training Procedure
147
+
148
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
149
+
150
+ ### Preprocessing [optional]
151
+
152
+ Leveraging large-scale unlabeled speech and text data, we pre-train SpeechT5 to learn a unified-modal representation, hoping to improve the modeling capability for both speech and text.
153
+
154
+
155
+ ### Training hyperparameters
156
+ - **Precision:** [More Information Needed] <!--fp16, bf16, fp8, fp32 -->
157
+ - **Regime:** [More Information Needed] <!--mixed precision or not -->
158
+
159
+ ### Speeds, Sizes, Times [optional]
160
+
161
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
162
+
163
+ [More Information Needed]
164
+
165
+ # Evaluation
166
+
167
+ <!-- This section describes the evaluation protocols and provides the results. -->
168
+
169
+ ## Testing Data, Factors & Metrics
170
+
171
+ ### Testing Data
172
+
173
+ <!-- This should link to a Data Card if possible. -->
174
+
175
+ [More Information Needed]
176
+
177
+ ### Factors
178
+
179
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
180
+
181
+ [More Information Needed]
182
+
183
+ ### Metrics
184
+
185
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## Results
190
+
191
+ [More Information Needed]
192
+
193
+ ### Summary
194
+
195
+
196
+
197
+ # Model Examination [optional]
198
+
199
+ <!-- Relevant interpretability work for the model goes here -->
200
+
201
+ Extensive evaluations show the superiority of the proposed SpeechT5 framework on a wide variety of spoken language processing tasks, including automatic speech recognition, speech synthesis, speech translation, voice conversion, speech enhancement, and speaker identification.
202
+
203
+ # Environmental Impact
204
+
205
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
206
+
207
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
208
+
209
+ - **Hardware Type:** [More Information Needed]
210
+ - **Hours used:** [More Information Needed]
211
+ - **Cloud Provider:** [More Information Needed]
212
+ - **Compute Region:** [More Information Needed]
213
+ - **Carbon Emitted:** [More Information Needed]
214
+
215
+ # Technical Specifications [optional]
216
+
217
+ ## Model Architecture and Objective
218
+
219
+ The SpeechT5 framework consists of a shared encoder-decoder network and six modal-specific (speech/text) pre/post-nets.
220
+
221
+ After preprocessing the input speech/text through the pre-nets, the shared encoder-decoder network models the sequence-to-sequence transformation, and then the post-nets generate the output in the speech/text modality based on the output of the decoder.
222
+
223
+ ## Compute Infrastructure
224
+
225
+ [More Information Needed]
226
+
227
+ ### Hardware
228
+
229
+ [More Information Needed]
230
+
231
+ ### Software
232
+
233
+ [More Information Needed]
234
+
235
+ # Citation [optional]
236
+
237
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
238
+
239
+ **BibTeX:**
240
+
241
+ ```bibtex
242
+ @inproceedings{ao-etal-2022-speecht5,
243
+ title = {{S}peech{T}5: Unified-Modal Encoder-Decoder Pre-Training for Spoken Language Processing},
244
+ author = {Ao, Junyi and Wang, Rui and Zhou, Long and Wang, Chengyi and Ren, Shuo and Wu, Yu and Liu, Shujie and Ko, Tom and Li, Qing and Zhang, Yu and Wei, Zhihua and Qian, Yao and Li, Jinyu and Wei, Furu},
245
+ booktitle = {Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},
246
+ month = {May},
247
+ year = {2022},
248
+ pages={5723--5738},
249
+ }
250
+ ```
251
+
252
+ # Glossary [optional]
253
+
254
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
255
+
256
+ - **text-to-speech** to synthesize audio
257
+
258
+ # More Information [optional]
259
+
260
+ [More Information Needed]
261
+
262
+ # Model Card Authors [optional]
263
+
264
+ Disclaimer: The team releasing SpeechT5 did not write a model card for this model so this model card has been written by the Hugging Face team.
265
+
266
+ # Model Card Contact
267
+
268
+ [More Information Needed]
269
+
270
+
271
+
added_tokens.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "<ctc_blank>": 80,
3
+ "<mask>": 79
4
+ }
config.json ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation_dropout": 0.1,
3
+ "apply_spec_augment": true,
4
+ "architectures": [
5
+ "SpeechT5ForTextToSpeech"
6
+ ],
7
+ "attention_dropout": 0.1,
8
+ "bos_token_id": 0,
9
+ "conv_bias": false,
10
+ "conv_dim": [
11
+ 512,
12
+ 512,
13
+ 512,
14
+ 512,
15
+ 512,
16
+ 512,
17
+ 512
18
+ ],
19
+ "conv_kernel": [
20
+ 10,
21
+ 3,
22
+ 3,
23
+ 3,
24
+ 3,
25
+ 2,
26
+ 2
27
+ ],
28
+ "conv_stride": [
29
+ 5,
30
+ 2,
31
+ 2,
32
+ 2,
33
+ 2,
34
+ 2,
35
+ 2
36
+ ],
37
+ "decoder_attention_heads": 12,
38
+ "decoder_ffn_dim": 3072,
39
+ "decoder_layerdrop": 0.1,
40
+ "decoder_layers": 6,
41
+ "decoder_start_token_id": 2,
42
+ "encoder_attention_heads": 12,
43
+ "encoder_ffn_dim": 3072,
44
+ "encoder_layerdrop": 0.1,
45
+ "encoder_layers": 12,
46
+ "encoder_max_relative_position": 160,
47
+ "eos_token_id": 2,
48
+ "feat_extract_activation": "gelu",
49
+ "feat_extract_norm": "group",
50
+ "feat_proj_dropout": 0.0,
51
+ "guided_attention_loss_num_heads": 2,
52
+ "guided_attention_loss_scale": 10.0,
53
+ "guided_attention_loss_sigma": 0.4,
54
+ "hidden_act": "gelu",
55
+ "hidden_dropout": 0.1,
56
+ "hidden_size": 768,
57
+ "initializer_range": 0.02,
58
+ "is_encoder_decoder": true,
59
+ "layer_norm_eps": 1e-05,
60
+ "mask_feature_length": 10,
61
+ "mask_feature_min_masks": 0,
62
+ "mask_feature_prob": 0.0,
63
+ "mask_time_length": 10,
64
+ "mask_time_min_masks": 2,
65
+ "mask_time_prob": 0.05,
66
+ "max_length": 1876,
67
+ "max_speech_positions": 1876,
68
+ "max_text_positions": 600,
69
+ "model_type": "speecht5",
70
+ "num_conv_pos_embedding_groups": 16,
71
+ "num_conv_pos_embeddings": 128,
72
+ "num_feat_extract_layers": 7,
73
+ "num_mel_bins": 80,
74
+ "pad_token_id": 1,
75
+ "positional_dropout": 0.1,
76
+ "reduction_factor": 2,
77
+ "scale_embedding": false,
78
+ "speaker_embedding_dim": 512,
79
+ "speech_decoder_postnet_dropout": 0.5,
80
+ "speech_decoder_postnet_kernel": 5,
81
+ "speech_decoder_postnet_layers": 5,
82
+ "speech_decoder_postnet_units": 256,
83
+ "speech_decoder_prenet_dropout": 0.5,
84
+ "speech_decoder_prenet_layers": 2,
85
+ "speech_decoder_prenet_units": 256,
86
+ "torch_dtype": "float32",
87
+ "transformers_version": "4.28.0.dev0",
88
+ "use_cache": true,
89
+ "use_guided_attention_loss": true,
90
+ "vocab_size": 81
91
+ }
preprocessor_config.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_normalize": false,
3
+ "feature_extractor_type": "SpeechT5FeatureExtractor",
4
+ "feature_size": 1,
5
+ "fmax": 7600,
6
+ "fmin": 80,
7
+ "frame_signal_scale": 1.0,
8
+ "hop_length": 16,
9
+ "mel_floor": 1e-10,
10
+ "num_mel_bins": 80,
11
+ "padding_side": "right",
12
+ "padding_value": 0.0,
13
+ "processor_class": "SpeechT5Processor",
14
+ "return_attention_mask": true,
15
+ "sampling_rate": 16000,
16
+ "win_function": "hann_window",
17
+ "win_length": 64
18
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d60d28067349ef66b50d8cd643ae56b6d6b8f27def929bc4ef6fcad907954190
3
+ size 585476837
special_tokens_map.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "eos_token": "</s>",
4
+ "mask_token": {
5
+ "content": "<mask>",
6
+ "lstrip": true,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false
10
+ },
11
+ "pad_token": "<pad>",
12
+ "unk_token": "<unk>"
13
+ }
spm_char.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7fcc48f3e225f627b1641db410ceb0c8649bd2b0c982e150b03f8be3728ab560
3
+ size 238473
tokenizer_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "eos_token": "</s>",
4
+ "model_max_length": 600,
5
+ "pad_token": "<pad>",
6
+ "processor_class": "SpeechT5Processor",
7
+ "sp_model_kwargs": {},
8
+ "tokenizer_class": "SpeechT5Tokenizer",
9
+ "unk_token": "<unk>"
10
+ }