lysandre HF staff commited on
Commit
83b7d03
1 Parent(s): 0824fc8

commit files to HF hub

Browse files
added_tokens.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "<ctc_blank>": 80,
3
+ "<mask>": 79
4
+ }
config.json ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "microsoft/speecht5_tts",
3
+ "activation_dropout": 0.1,
4
+ "apply_spec_augment": true,
5
+ "architectures": [
6
+ "SpeechT5ForTextToSpeech"
7
+ ],
8
+ "attention_dropout": 0.1,
9
+ "bos_token_id": 0,
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
+ "custom_pipelines": {
39
+ "text-to-speech": {
40
+ "impl": "tts.TTSPipeline",
41
+ "pt": [
42
+ "SpeechT5ForTextToSpeech"
43
+ ],
44
+ "tf": []
45
+ }
46
+ },
47
+ "decoder_attention_heads": 12,
48
+ "decoder_ffn_dim": 3072,
49
+ "decoder_layerdrop": 0.1,
50
+ "decoder_layers": 6,
51
+ "decoder_start_token_id": 2,
52
+ "encoder_attention_heads": 12,
53
+ "encoder_ffn_dim": 3072,
54
+ "encoder_layerdrop": 0.1,
55
+ "encoder_layers": 12,
56
+ "encoder_max_relative_position": 160,
57
+ "eos_token_id": 2,
58
+ "feat_extract_activation": "gelu",
59
+ "feat_extract_norm": "group",
60
+ "feat_proj_dropout": 0.0,
61
+ "guided_attention_loss_num_heads": 2,
62
+ "guided_attention_loss_scale": 10.0,
63
+ "guided_attention_loss_sigma": 0.4,
64
+ "hidden_act": "gelu",
65
+ "hidden_dropout": 0.1,
66
+ "hidden_size": 768,
67
+ "initializer_range": 0.02,
68
+ "is_encoder_decoder": true,
69
+ "layer_norm_eps": 1e-05,
70
+ "mask_feature_length": 10,
71
+ "mask_feature_min_masks": 0,
72
+ "mask_feature_prob": 0.0,
73
+ "mask_time_length": 10,
74
+ "mask_time_min_masks": 2,
75
+ "mask_time_prob": 0.05,
76
+ "max_length": 1876,
77
+ "max_speech_positions": 1876,
78
+ "max_text_positions": 600,
79
+ "model_type": "speecht5",
80
+ "num_conv_pos_embedding_groups": 16,
81
+ "num_conv_pos_embeddings": 128,
82
+ "num_feat_extract_layers": 7,
83
+ "num_mel_bins": 80,
84
+ "pad_token_id": 1,
85
+ "positional_dropout": 0.1,
86
+ "reduction_factor": 2,
87
+ "scale_embedding": false,
88
+ "speaker_embedding_dim": 512,
89
+ "speech_decoder_postnet_dropout": 0.5,
90
+ "speech_decoder_postnet_kernel": 5,
91
+ "speech_decoder_postnet_layers": 5,
92
+ "speech_decoder_postnet_units": 256,
93
+ "speech_decoder_prenet_dropout": 0.5,
94
+ "speech_decoder_prenet_layers": 2,
95
+ "speech_decoder_prenet_units": 256,
96
+ "torch_dtype": "float32",
97
+ "transformers_version": "4.28.1",
98
+ "use_cache": true,
99
+ "use_guided_attention_loss": true,
100
+ "vocab_size": 81
101
+ }
preprocessor_config.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "n_fft": 1024,
11
+ "n_freqs": 513,
12
+ "num_mel_bins": 80,
13
+ "padding_side": "right",
14
+ "padding_value": 0.0,
15
+ "processor_class": "SpeechT5Processor",
16
+ "reduction_factor": 2,
17
+ "return_attention_mask": true,
18
+ "sample_size": 1024,
19
+ "sample_stride": 256,
20
+ "sampling_rate": 16000,
21
+ "win_function": "hann_window",
22
+ "win_length": 64
23
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eccce95745831a1915292135e542097cc4d6bf9cb966331c1e99d6da40aa2330
3
+ size 585479749
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,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "clean_up_tokenization_spaces": true,
4
+ "eos_token": "</s>",
5
+ "model_max_length": 600,
6
+ "pad_token": "<pad>",
7
+ "processor_class": "SpeechT5Processor",
8
+ "sp_model_kwargs": {},
9
+ "tokenizer_class": "SpeechT5Tokenizer",
10
+ "unk_token": "<unk>"
11
+ }
tts.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from datasets import load_dataset
3
+ from transformers import Pipeline, SpeechT5Processor, SpeechT5HifiGan
4
+
5
+
6
+ class TTSPipeline(Pipeline):
7
+ def __init__(self, *args, vocoder=None, processor=None, **kwargs):
8
+ super().__init__(*args, **kwargs)
9
+
10
+ if vocoder is None:
11
+ raise ValueError("Must pass a vocoder to the TTSPipeline.")
12
+
13
+ if processor is None:
14
+ raise ValueError("Must pass a processor to the TTSPipeline.")
15
+
16
+ if isinstance(vocoder, str):
17
+ vocoder = SpeechT5HifiGan.from_pretrained(vocoder)
18
+
19
+ if isinstance(processor, str):
20
+ processor = SpeechT5Processor.from_pretrained(processor)
21
+
22
+ self.processor = processor
23
+ self.vocoder = vocoder
24
+
25
+ def preprocess(self, text, speaker_embeddings=None):
26
+ inputs = self.processor(text=text, return_tensors='pt')
27
+
28
+ if speaker_embeddings is None:
29
+ embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
30
+ speaker_embeddings = torch.tensor(embeddings_dataset[7305]["xvector"]).unsqueeze(0)
31
+
32
+ return {'inputs': inputs, 'speaker_embeddings': speaker_embeddings}
33
+
34
+ def _forward(self, model_inputs):
35
+ inputs = model_inputs['inputs']
36
+ speaker_embeddings = model_inputs['speaker_embeddings']
37
+
38
+ with torch.no_grad():
39
+ speech = self.model.generate_speech(inputs['input_ids'], speaker_embeddings, vocoder=self.vocoder)
40
+
41
+ return speech
42
+
43
+ def _sanitize_parameters(self, **pipeline_parameters):
44
+ return {}, {}, {}
45
+
46
+ def postprocess(self, speech):
47
+ return speech