ccoreilly commited on
Commit
ccb20f4
1 Parent(s): daabc35

import & fix

Browse files
Files changed (8) hide show
  1. README.md +24 -6
  2. app.py +77 -0
  3. best_model.pth +3 -0
  4. config.json +262 -0
  5. packages.txt +2 -0
  6. requirements.txt +1 -0
  7. speaker_map.json +10 -0
  8. speakers.pth +3 -0
README.md CHANGED
@@ -1,12 +1,30 @@
1
  ---
2
- title: Coqui Tts Cat
3
- emoji: 📉
4
- colorFrom: yellow
5
- colorTo: pink
6
  sdk: gradio
7
- sdk_version: 3.28.0
8
  app_file: app.py
9
  pinned: false
10
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
1
  ---
2
+ title: BSC VITS
3
+ emoji: 🗣️
4
+ colorFrom: blue
5
+ colorTo: white
6
  sdk: gradio
 
7
  app_file: app.py
8
  pinned: false
9
  ---
10
+ # Configuration
11
+ `title`: _string_
12
+ Display title for the Space
13
+ `emoji`: _string_
14
+ Space emoji (emoji-only character allowed)
15
+ `colorFrom`: _string_
16
+ Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
17
+ `colorTo`: _string_
18
+ Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
19
+ `sdk`: _string_
20
+ Can be either `gradio`, `streamlit`, or `static`
21
+ `sdk_version` : _string_
22
+ Only applicable for `streamlit` SDK.
23
+ See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.
24
 
25
+ `app_file`: _string_
26
+ Path to your main application file (which contains either `gradio` or `streamlit` Python code, or `static` html code).
27
+ Path is relative to the root of the repository.
28
+
29
+ `pinned`: _boolean_
30
+ Whether the Space stays on top of your list.
app.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tempfile
2
+ from typing import Optional
3
+ from TTS.config import load_config
4
+ import gradio as gr
5
+ import numpy as np
6
+ import os
7
+ import json
8
+ from TTS.utils.manage import ModelManager
9
+ from TTS.utils.synthesizer import Synthesizer
10
+
11
+
12
+ MAX_TXT_LEN = 100
13
+
14
+ SPEAKERS = ['f_cen_05', 'f_cen_81', 'f_occ_31', 'f_occ_de', 'f_sep_31', 'm_cen_08', 'm_occ_44', 'm_val_89']
15
+
16
+ def tts(text: str, speaker_idx: str=None):
17
+ if len(text) > MAX_TXT_LEN:
18
+ text = text[:MAX_TXT_LEN]
19
+ print(f"Input text was cutoff since it went over the {MAX_TXT_LEN} character limit.")
20
+ print(text)
21
+
22
+ model_path = os.getcwd() + "/best_model.pth"
23
+ config_path = os.getcwd() + "/config.json"
24
+ speakers_file_path = os.getcwd() + "/speakers.pth"
25
+ speakers_maping_path = os.getcwd() + "/speaker_map.json"
26
+ vocoder_path = None
27
+ vocoder_config_path = None
28
+
29
+ synthesizer = Synthesizer(
30
+ model_path, config_path, speakers_file_path, None, vocoder_path, vocoder_config_path,
31
+ )
32
+
33
+ # Map speaker aliases to speaker ids
34
+ with open(speakers_maping_path, 'r') as fp:
35
+ maping = json.load(fp)
36
+
37
+ speaker_idx = maping[speaker_idx]
38
+
39
+ # synthesize
40
+ if synthesizer is None:
41
+ raise NameError("model not found")
42
+ wavs = synthesizer.tts(text, speaker_idx)
43
+ # return output
44
+ with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
45
+ synthesizer.save_wav(wavs, fp)
46
+ return fp.name
47
+
48
+
49
+ description="""
50
+ 1️⃣ Introdueix el text a sintetitzar.
51
+
52
+ 2️⃣ Selecciona una veu en el desplegable.
53
+
54
+ 3️⃣ Gaudeix!
55
+ """
56
+ article= ""
57
+
58
+ iface = gr.Interface(
59
+ fn=tts,
60
+ inputs=[
61
+ gr.inputs.Textbox(
62
+ label="Text",
63
+ default="Introdueix el text a sintetitzar.",
64
+ ),
65
+ gr.inputs.Dropdown(label="Selecciona un parlant", choices=SPEAKERS, default=None)
66
+ ],
67
+ outputs=gr.outputs.Audio(label="Output",type="filepath"),
68
+ title="🗣️ TTS Català Multi Parlant - VITS 🗣️",
69
+ theme="grass",
70
+ description=description,
71
+ article=article,
72
+ allow_flagging=False,
73
+ flagging_options=['error', 'bad-quality', 'wrong-pronounciation'],
74
+ layout="vertical",
75
+ live=False
76
+ )
77
+ iface.launch(share=False)
best_model.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b15fa7d2052bada1cf421e49d2d03b00e95b49fcd0e42b7af1d92da2880cdecc
3
+ size 1038659133
config.json ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "output_path": "/gpfs/projects/bsc88/speech/tts/TTS_v0.8.0/recipes/multispeaker/experiments_from_previous",
3
+ "logger_uri": null,
4
+ "run_name": "multispeaker_vits_ca_1e4_1e4_32",
5
+ "project_name": null,
6
+ "run_description": "\ud83d\udc38Coqui trainer run.",
7
+ "print_step": 25,
8
+ "plot_step": 100,
9
+ "model_param_stats": false,
10
+ "wandb_entity": null,
11
+ "dashboard_logger": "tensorboard",
12
+ "log_model_step": 1000,
13
+ "save_step": 1000,
14
+ "save_n_checkpoints": 5,
15
+ "save_checkpoints": true,
16
+ "save_all_best": true,
17
+ "save_best_after": 10000,
18
+ "target_loss": null,
19
+ "print_eval": true,
20
+ "test_delay_epochs": -1,
21
+ "run_eval": true,
22
+ "run_eval_steps": null,
23
+ "distributed_backend": "nccl",
24
+ "distributed_url": "tcp://localhost:54321",
25
+ "mixed_precision": false,
26
+ "epochs": 1000,
27
+ "batch_size": 16,
28
+ "eval_batch_size": 8,
29
+ "grad_clip": [
30
+ 1000.0,
31
+ 1000.0
32
+ ],
33
+ "scheduler_after_epoch": true,
34
+ "lr": 0.001,
35
+ "optimizer": "AdamW",
36
+ "optimizer_params": {
37
+ "betas": [
38
+ 0.8,
39
+ 0.99
40
+ ],
41
+ "eps": 1e-09,
42
+ "weight_decay": 0.01
43
+ },
44
+ "lr_scheduler": "",
45
+ "lr_scheduler_params": null,
46
+ "use_grad_scaler": false,
47
+ "cudnn_enable": true,
48
+ "cudnn_deterministic": false,
49
+ "cudnn_benchmark": false,
50
+ "training_seed": 54321,
51
+ "model": "vits",
52
+ "num_loader_workers": 4,
53
+ "num_eval_loader_workers": 4,
54
+ "use_noise_augment": false,
55
+ "audio": {
56
+ "fft_size": 1024,
57
+ "sample_rate": 22050,
58
+ "win_length": 1024,
59
+ "hop_length": 256,
60
+ "num_mels": 80,
61
+ "mel_fmin": 0,
62
+ "mel_fmax": null
63
+ },
64
+ "use_phonemes": true,
65
+ "phonemizer": "espeak",
66
+ "phoneme_language": "ca",
67
+ "compute_input_seq_cache": true,
68
+ "text_cleaner": "multilingual_cleaners",
69
+ "enable_eos_bos_chars": false,
70
+ "test_sentences_file": "",
71
+ "phoneme_cache_path": "/gpfs/projects/bsc88/speech/tts/TTS_v0.8.0/recipes/multispeaker/phoneme_cache",
72
+ "characters": {
73
+ "characters_class": "TTS.tts.utils.text.characters.IPAPhonemes",
74
+ "vocab_dict": null,
75
+ "pad": "<PAD>",
76
+ "eos": "<EOS>",
77
+ "bos": "<BOS>",
78
+ "blank": "<BLNK>",
79
+ "characters": "iy\u0268\u0289\u026fu\u026a\u028f\u028ae\u00f8\u0258\u0259\u0275\u0264o\u025b\u0153\u025c\u025e\u028c\u0254\u00e6\u0250a\u0276\u0251\u0252\u1d7b\u0298\u0253\u01c0\u0257\u01c3\u0284\u01c2\u0260\u01c1\u029bpbtd\u0288\u0256c\u025fk\u0261q\u0262\u0294\u0274\u014b\u0272\u0273n\u0271m\u0299r\u0280\u2c71\u027e\u027d\u0278\u03b2fv\u03b8\u00f0sz\u0283\u0292\u0282\u0290\u00e7\u029dx\u0263\u03c7\u0281\u0127\u0295h\u0266\u026c\u026e\u028b\u0279\u027bj\u0270l\u026d\u028e\u029f\u02c8\u02cc\u02d0\u02d1\u028dw\u0265\u029c\u02a2\u02a1\u0255\u0291\u027a\u0267\u02b2\u025a\u02de\u026b",
80
+ "punctuations": "!'(),-.:;? ",
81
+ "phonemes": null,
82
+ "is_unique": false,
83
+ "is_sorted": true
84
+ },
85
+ "add_blank": true,
86
+ "batch_group_size": 5,
87
+ "loss_masking": null,
88
+ "min_audio_len": 1,
89
+ "max_audio_len": Infinity,
90
+ "min_text_len": 1,
91
+ "max_text_len": 325,
92
+ "compute_f0": false,
93
+ "compute_linear_spec": true,
94
+ "precompute_num_workers": 0,
95
+ "start_by_longest": false,
96
+ "datasets": [
97
+ {
98
+ "formatter": "vctk_old",
99
+ "dataset_name": "vctk_old",
100
+ "path": "/gpfs/scratch/bsc88/bsc88474/data/multispeaker_ca",
101
+ "meta_file_train": "",
102
+ "ignored_speakers": [
103
+ "uri",
104
+ "09796",
105
+ "05450"
106
+ ],
107
+ "language": "ca",
108
+ "meta_file_val": "",
109
+ "meta_file_attn_mask": ""
110
+ }
111
+ ],
112
+ "test_sentences": [
113
+ [
114
+ "Per exemple, dels nostres bancs que inverteixen en armament de les nostres empreses."
115
+ ],
116
+ [
117
+ "Preguntin-se si aix\u00f2 era necessari."
118
+ ],
119
+ [
120
+ "La suposada ocultaci\u00f3 dels informes que advertien de risc s\u00edsmic."
121
+ ],
122
+ [
123
+ "\u00c9s de 633 milions d'euros quan es far\u00e0 la publicaci\u00f3 detallada."
124
+ ]
125
+ ],
126
+ "eval_split_max_size": null,
127
+ "eval_split_size": 0.01,
128
+ "use_speaker_weighted_sampler": false,
129
+ "speaker_weighted_sampler_alpha": 1.0,
130
+ "use_language_weighted_sampler": false,
131
+ "language_weighted_sampler_alpha": 1.0,
132
+ "use_length_weighted_sampler": false,
133
+ "length_weighted_sampler_alpha": 1.0,
134
+ "model_args": {
135
+ "num_chars": 131,
136
+ "out_channels": 513,
137
+ "spec_segment_size": 32,
138
+ "hidden_channels": 192,
139
+ "hidden_channels_ffn_text_encoder": 768,
140
+ "num_heads_text_encoder": 2,
141
+ "num_layers_text_encoder": 6,
142
+ "kernel_size_text_encoder": 3,
143
+ "dropout_p_text_encoder": 0.1,
144
+ "dropout_p_duration_predictor": 0.5,
145
+ "kernel_size_posterior_encoder": 5,
146
+ "dilation_rate_posterior_encoder": 1,
147
+ "num_layers_posterior_encoder": 16,
148
+ "kernel_size_flow": 5,
149
+ "dilation_rate_flow": 1,
150
+ "num_layers_flow": 4,
151
+ "resblock_type_decoder": "1",
152
+ "resblock_kernel_sizes_decoder": [
153
+ 3,
154
+ 7,
155
+ 11
156
+ ],
157
+ "resblock_dilation_sizes_decoder": [
158
+ [
159
+ 1,
160
+ 3,
161
+ 5
162
+ ],
163
+ [
164
+ 1,
165
+ 3,
166
+ 5
167
+ ],
168
+ [
169
+ 1,
170
+ 3,
171
+ 5
172
+ ]
173
+ ],
174
+ "upsample_rates_decoder": [
175
+ 8,
176
+ 8,
177
+ 2,
178
+ 2
179
+ ],
180
+ "upsample_initial_channel_decoder": 512,
181
+ "upsample_kernel_sizes_decoder": [
182
+ 16,
183
+ 16,
184
+ 4,
185
+ 4
186
+ ],
187
+ "periods_multi_period_discriminator": [
188
+ 2,
189
+ 3,
190
+ 5,
191
+ 7,
192
+ 11
193
+ ],
194
+ "use_sdp": true,
195
+ "noise_scale": 1.0,
196
+ "inference_noise_scale": 0.667,
197
+ "length_scale": 1.0,
198
+ "noise_scale_dp": 1.0,
199
+ "inference_noise_scale_dp": 1.0,
200
+ "max_inference_len": null,
201
+ "init_discriminator": true,
202
+ "use_spectral_norm_disriminator": false,
203
+ "use_speaker_embedding": true,
204
+ "num_speakers": 257,
205
+ "speakers_file": "/home/user/app/speakers.pth",
206
+ "d_vector_file": null,
207
+ "speaker_embedding_channels": 256,
208
+ "use_d_vector_file": false,
209
+ "d_vector_dim": 0,
210
+ "detach_dp_input": true,
211
+ "use_language_embedding": false,
212
+ "embedded_language_dim": 4,
213
+ "num_languages": 0,
214
+ "language_ids_file": null,
215
+ "use_speaker_encoder_as_loss": false,
216
+ "speaker_encoder_config_path": "",
217
+ "speaker_encoder_model_path": "",
218
+ "condition_dp_on_speaker": true,
219
+ "freeze_encoder": false,
220
+ "freeze_DP": false,
221
+ "freeze_PE": false,
222
+ "freeze_flow_decoder": false,
223
+ "freeze_waveform_decoder": false,
224
+ "encoder_sample_rate": null,
225
+ "interpolate_z": true,
226
+ "reinit_DP": false,
227
+ "reinit_text_encoder": false
228
+ },
229
+ "lr_gen": 0.0001,
230
+ "lr_disc": 0.0001,
231
+ "lr_scheduler_gen": "ExponentialLR",
232
+ "lr_scheduler_gen_params": {
233
+ "gamma": 0.999875,
234
+ "last_epoch": -1
235
+ },
236
+ "lr_scheduler_disc": "ExponentialLR",
237
+ "lr_scheduler_disc_params": {
238
+ "gamma": 0.999875,
239
+ "last_epoch": -1
240
+ },
241
+ "kl_loss_alpha": 1.0,
242
+ "disc_loss_alpha": 1.0,
243
+ "gen_loss_alpha": 1.0,
244
+ "feat_loss_alpha": 1.0,
245
+ "mel_loss_alpha": 45.0,
246
+ "dur_loss_alpha": 1.0,
247
+ "speaker_encoder_loss_alpha": 1.0,
248
+ "return_wav": true,
249
+ "use_weighted_sampler": false,
250
+ "weighted_sampler_attrs": null,
251
+ "weighted_sampler_multipliers": null,
252
+ "r": 1,
253
+ "num_speakers": 257,
254
+ "use_speaker_embedding": true,
255
+ "speakers_file": "/home/user/app/speakers.pth",
256
+ "speaker_embedding_channels": 256,
257
+ "language_ids_file": null,
258
+ "use_language_embedding": false,
259
+ "use_d_vector_file": false,
260
+ "d_vector_file": null,
261
+ "d_vector_dim": 0
262
+ }
packages.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ libsndfile1
2
+ espeak-ng
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ git+https://github.com/coqui-ai/TTS@dev#egg=TTS
speaker_map.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "f_cen_05": "05739",
3
+ "f_cen_81": "8162d651b6211f06f655a69cd7fdd383d6b4287e9ba132b9898ef9ac8687349e777626333d23bed93f9264aae965efb14ed650cb64fd0ad90494aff903eaef11",
4
+ "f_occ_31": "31535cb2ece4710d08fdbeefb6f8f75ed093fee4cf8573bd601d960f8c6156f0fd0a85712761691e86e31160b993ee0eacb10c4c8aed000cc394cf7c7d207a7e",
5
+ "f_occ_de": "dee065b956b99b10db4763759d64c41791af1a7e77f1864f90a2b0847a12633dcf9bc108db7eaf73cc8d0e750f5c37383a56cd77cc2276d3960104c6bebe6346",
6
+ "f_sep_31": "31e6f3a011661320b2e59b6f8be43f6db2243e9feabc2b9787c1413788e13eb0e5810bed983bf7ff66e46417d183a91ed50b3b9be9d89e4f51aada72293b9881",
7
+ "m_cen_08": "08935",
8
+ "m_occ_44": "30b1f81c579755895581259d79a8a5a3ca45b908b0bd14ad1c6418f39aa1e2f47cb4749c69b5440cdb92e3bafb772e19e7bc2b16d196b061addd173a1309e491",
9
+ "m_val_89": "896256329fbeb5b8116349c31d8a39a7d36d5f970d48558e1db5417d611e240e4dbf473f6e49137f7aa6116394b7deabb0bbec4a014896cdc9484ee91458117d"
10
+ }
speakers.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6dacda0b8dd3e111c5072f8f33c08b4a29b92ac79aaf22ceca912d01e7deb905
3
+ size 30191