Spaces:
Build error
Build error
persian tts
Browse files- .gitattributes +1 -0
- app.py +65 -0
- best_model.pth +3 -0
- config.json +189 -0
- packages.txt +2 -0
- requirements.txt +1 -0
.gitattributes
CHANGED
|
@@ -32,3 +32,4 @@ saved_model/**/* 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
|
|
|
|
|
|
| 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
|
| 35 |
+
best_model.pth filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import tempfile
|
| 3 |
+
from typing import Optional
|
| 4 |
+
from TTS.config import load_config
|
| 5 |
+
import gradio as gr
|
| 6 |
+
import numpy as np
|
| 7 |
+
import os
|
| 8 |
+
import json
|
| 9 |
+
from TTS.utils.manage import ModelManager
|
| 10 |
+
from TTS.utils.synthesizer import Synthesizer
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
MAX_TXT_LEN = 800
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def tts(text: str):
|
| 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 |
+
|
| 25 |
+
|
| 26 |
+
synthesizer = Synthesizer(
|
| 27 |
+
model_path, config_path, speakers_file_path
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
# synthesize
|
| 32 |
+
if synthesizer is None:
|
| 33 |
+
raise NameError("model not found")
|
| 34 |
+
wavs = synthesizer.tts(text, speaker_idx)
|
| 35 |
+
# return output
|
| 36 |
+
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
| 37 |
+
synthesizer.save_wav(wavs, fp)
|
| 38 |
+
return fp.name
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
description="""
|
| 42 |
+
This is a demo of first public free persian text to speech model.
|
| 43 |
+
Model trained on this dataset : https://www.kaggle.com/datasets/magnoliasis/persian-tts-dataset-famale
|
| 44 |
+
"""
|
| 45 |
+
article= ""
|
| 46 |
+
|
| 47 |
+
iface = gr.Interface(
|
| 48 |
+
fn=tts,
|
| 49 |
+
inputs=[
|
| 50 |
+
gr.inputs.Textbox(
|
| 51 |
+
label="Text",
|
| 52 |
+
default="زندگی فقط یک بار است؛ از آن به خوبی استفاده کن",
|
| 53 |
+
)
|
| 54 |
+
],
|
| 55 |
+
outputs=gr.outputs.Audio(label="Output"),
|
| 56 |
+
title="🗣️Persian ttt - glow_tts 🗣️",
|
| 57 |
+
theme="grass",
|
| 58 |
+
description=description,
|
| 59 |
+
article=article,
|
| 60 |
+
allow_flagging=False,
|
| 61 |
+
flagging_options=['error', 'bad-quality', 'wrong-pronounciation'],
|
| 62 |
+
layout="vertical",
|
| 63 |
+
live=False
|
| 64 |
+
)
|
| 65 |
+
iface.launch(share=False)
|
best_model.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:aef214c5d0c32265991b5a6ae2b37ae739021e010ed17bed28e20088a73ba680
|
| 3 |
+
size 343874215
|
config.json
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"output_path": "/kaggle/working/train_output",
|
| 3 |
+
"logger_uri": null,
|
| 4 |
+
"run_name": "run",
|
| 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": null,
|
| 13 |
+
"save_step": 1000,
|
| 14 |
+
"save_n_checkpoints": 5,
|
| 15 |
+
"save_checkpoints": true,
|
| 16 |
+
"save_all_best": false,
|
| 17 |
+
"save_best_after": 10000,
|
| 18 |
+
"target_loss": null,
|
| 19 |
+
"print_eval": false,
|
| 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": true,
|
| 26 |
+
"epochs": 1000,
|
| 27 |
+
"batch_size": 8,
|
| 28 |
+
"eval_batch_size": 4,
|
| 29 |
+
"grad_clip": 5.0,
|
| 30 |
+
"scheduler_after_epoch": true,
|
| 31 |
+
"lr": 0.001,
|
| 32 |
+
"optimizer": "RAdam",
|
| 33 |
+
"optimizer_params": {
|
| 34 |
+
"betas": [
|
| 35 |
+
0.9,
|
| 36 |
+
0.998
|
| 37 |
+
],
|
| 38 |
+
"weight_decay": 1e-06
|
| 39 |
+
},
|
| 40 |
+
"lr_scheduler": "NoamLR",
|
| 41 |
+
"lr_scheduler_params": {
|
| 42 |
+
"warmup_steps": 4000
|
| 43 |
+
},
|
| 44 |
+
"use_grad_scaler": false,
|
| 45 |
+
"cudnn_enable": true,
|
| 46 |
+
"cudnn_deterministic": false,
|
| 47 |
+
"cudnn_benchmark": false,
|
| 48 |
+
"training_seed": 54321,
|
| 49 |
+
"model": "glow_tts",
|
| 50 |
+
"num_loader_workers": 0,
|
| 51 |
+
"num_eval_loader_workers": 0,
|
| 52 |
+
"use_noise_augment": false,
|
| 53 |
+
"audio": {
|
| 54 |
+
"fft_size": 1024,
|
| 55 |
+
"win_length": 1024,
|
| 56 |
+
"hop_length": 256,
|
| 57 |
+
"frame_shift_ms": null,
|
| 58 |
+
"frame_length_ms": null,
|
| 59 |
+
"stft_pad_mode": "reflect",
|
| 60 |
+
"sample_rate": 24000,
|
| 61 |
+
"resample": false,
|
| 62 |
+
"preemphasis": 0.0,
|
| 63 |
+
"ref_level_db": 20,
|
| 64 |
+
"do_sound_norm": false,
|
| 65 |
+
"log_func": "np.log10",
|
| 66 |
+
"do_trim_silence": true,
|
| 67 |
+
"trim_db": 45,
|
| 68 |
+
"do_rms_norm": false,
|
| 69 |
+
"db_level": null,
|
| 70 |
+
"power": 1.5,
|
| 71 |
+
"griffin_lim_iters": 60,
|
| 72 |
+
"num_mels": 80,
|
| 73 |
+
"mel_fmin": 0.0,
|
| 74 |
+
"mel_fmax": null,
|
| 75 |
+
"spec_gain": 20,
|
| 76 |
+
"do_amp_to_db_linear": true,
|
| 77 |
+
"do_amp_to_db_mel": true,
|
| 78 |
+
"pitch_fmax": 640.0,
|
| 79 |
+
"pitch_fmin": 1.0,
|
| 80 |
+
"signal_norm": true,
|
| 81 |
+
"min_level_db": -100,
|
| 82 |
+
"symmetric_norm": true,
|
| 83 |
+
"max_norm": 4.0,
|
| 84 |
+
"clip_norm": true,
|
| 85 |
+
"stats_path": null
|
| 86 |
+
},
|
| 87 |
+
"use_phonemes": true,
|
| 88 |
+
"phonemizer": "espeak",
|
| 89 |
+
"phoneme_language": "fa",
|
| 90 |
+
"compute_input_seq_cache": false,
|
| 91 |
+
"text_cleaner": "basic_cleaners",
|
| 92 |
+
"enable_eos_bos_chars": false,
|
| 93 |
+
"test_sentences_file": "",
|
| 94 |
+
"phoneme_cache_path": "/kaggle/working/train_output/phoneme_cache",
|
| 95 |
+
"characters": {
|
| 96 |
+
"characters_class": "TTS.tts.utils.text.characters.IPAPhonemes",
|
| 97 |
+
"vocab_dict": null,
|
| 98 |
+
"pad": "<PAD>",
|
| 99 |
+
"eos": "<EOS>",
|
| 100 |
+
"bos": "<BOS>",
|
| 101 |
+
"blank": "<BLNK>",
|
| 102 |
+
"characters": "\u02c8\u02cc\u02d0\u02d1pbtd\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\u029faegiouwy\u026a\u028a\u0329\u00e6\u0251\u0254\u0259\u025a\u025b\u025d\u0268\u0303\u0289\u028c\u028d0123456789\"#$%*+/=ABCDEFGHIJKLMNOPRSTUVWXYZ[]^_{}",
|
| 103 |
+
"punctuations": "!(),-.:;? \u0320\u060c\u061b\u061f\u200c<>",
|
| 104 |
+
"phonemes": "\u02c8\u02cc\u02d0\u02d1pbtd\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\u029faegiouwy\u026a\u028a\u0329\u00e6\u0251\u0254\u0259\u025a\u025b\u025d\u0268\u0303\u0289\u028c\u028d0123456789\"#$%*+/=ABCDEFGHIJKLMNOPRSTUVWXYZ[]^_{}",
|
| 105 |
+
"is_unique": true,
|
| 106 |
+
"is_sorted": true
|
| 107 |
+
},
|
| 108 |
+
"add_blank": false,
|
| 109 |
+
"batch_group_size": 0,
|
| 110 |
+
"loss_masking": null,
|
| 111 |
+
"min_audio_len": 1,
|
| 112 |
+
"max_audio_len": Infinity,
|
| 113 |
+
"min_text_len": 1,
|
| 114 |
+
"max_text_len": Infinity,
|
| 115 |
+
"compute_f0": false,
|
| 116 |
+
"compute_linear_spec": false,
|
| 117 |
+
"precompute_num_workers": 0,
|
| 118 |
+
"start_by_longest": false,
|
| 119 |
+
"shuffle": false,
|
| 120 |
+
"drop_last": false,
|
| 121 |
+
"datasets": [
|
| 122 |
+
{
|
| 123 |
+
"formatter": "mozilla",
|
| 124 |
+
"dataset_name": "",
|
| 125 |
+
"path": "/kaggle/input/persian-tts-dataset-famale",
|
| 126 |
+
"meta_file_train": "metadata.csv",
|
| 127 |
+
"ignored_speakers": null,
|
| 128 |
+
"language": "",
|
| 129 |
+
"meta_file_val": "",
|
| 130 |
+
"meta_file_attn_mask": ""
|
| 131 |
+
}
|
| 132 |
+
],
|
| 133 |
+
"test_sentences": [
|
| 134 |
+
"\u0633\u0644\u0637\u0627\u0646 \u0645\u062d\u0645\u0648\u062f \u062f\u0631 \u0632\u0645\u0633\u062a\u0627\u0646\u06cc \u0633\u062e\u062a \u0628\u0647 \u0637\u0644\u062e\u06a9 \u06af\u0641\u062a \u06a9\u0647: \u0628\u0627 \u0627\u06cc\u0646 \u062c\u0627\u0645\u0647 \u06cc \u06cc\u06a9 \u0644\u0627 \u062f\u0631 \u0627\u06cc\u0646 \u0633\u0631\u0645\u0627 \u0686\u0647 \u0645\u06cc \u06a9\u0646\u06cc ",
|
| 135 |
+
"\u0645\u0631\u062f\u06cc \u0646\u0632\u062f \u0628\u0642\u0627\u0644\u06cc \u0622\u0645\u062f \u0648 \u06af\u0641\u062a \u067e\u06cc\u0627\u0632 \u0647\u0645 \u062f\u0647 \u062a\u0627 \u062f\u0647\u0627\u0646 \u0628\u062f\u0627\u0646 \u062e\u0648 \u0634\u0628\u0648\u06cc \u0633\u0627\u0632\u0645.",
|
| 136 |
+
"\u0627\u0632 \u0645\u0627\u0644 \u062e\u0648\u062f \u067e\u0627\u0631\u0647 \u0627\u06cc \u06af\u0648\u0634\u062a \u0628\u0633\u062a\u0627\u0646 \u0648 \u0632\u06cc\u0631\u0647 \u0628\u0627\u06cc\u06cc \u0645\u0639\u0637\u0651\u0631 \u0628\u0633\u0627\u0632",
|
| 137 |
+
"\u06cc\u06a9 \u0628\u0627\u0631 \u0647\u0645 \u0627\u0632 \u062c\u0647\u0646\u0645 \u0628\u06af\u0648\u06cc\u06cc\u062f.",
|
| 138 |
+
"\u06cc\u06a9\u06cc \u0627\u0633\u0628\u06cc \u0628\u0647 \u0639\u0627\u0631\u06cc\u062a \u062e\u0648\u0627\u0633\u062a"
|
| 139 |
+
],
|
| 140 |
+
"eval_split_max_size": null,
|
| 141 |
+
"eval_split_size": 0.01,
|
| 142 |
+
"use_speaker_weighted_sampler": false,
|
| 143 |
+
"speaker_weighted_sampler_alpha": 1.0,
|
| 144 |
+
"use_language_weighted_sampler": false,
|
| 145 |
+
"language_weighted_sampler_alpha": 1.0,
|
| 146 |
+
"use_length_weighted_sampler": false,
|
| 147 |
+
"length_weighted_sampler_alpha": 1.0,
|
| 148 |
+
"num_chars": 156,
|
| 149 |
+
"encoder_type": "rel_pos_transformer",
|
| 150 |
+
"encoder_params": {
|
| 151 |
+
"kernel_size": 3,
|
| 152 |
+
"dropout_p": 0.1,
|
| 153 |
+
"num_layers": 6,
|
| 154 |
+
"num_heads": 2,
|
| 155 |
+
"hidden_channels_ffn": 768,
|
| 156 |
+
"input_length": null
|
| 157 |
+
},
|
| 158 |
+
"use_encoder_prenet": true,
|
| 159 |
+
"hidden_channels_enc": 192,
|
| 160 |
+
"hidden_channels_dec": 192,
|
| 161 |
+
"hidden_channels_dp": 256,
|
| 162 |
+
"dropout_p_dp": 0.1,
|
| 163 |
+
"dropout_p_dec": 0.05,
|
| 164 |
+
"mean_only": true,
|
| 165 |
+
"out_channels": 80,
|
| 166 |
+
"num_flow_blocks_dec": 12,
|
| 167 |
+
"inference_noise_scale": 0.0,
|
| 168 |
+
"kernel_size_dec": 5,
|
| 169 |
+
"dilation_rate": 1,
|
| 170 |
+
"num_block_layers": 4,
|
| 171 |
+
"num_speakers": 0,
|
| 172 |
+
"c_in_channels": 0,
|
| 173 |
+
"num_splits": 4,
|
| 174 |
+
"num_squeeze": 2,
|
| 175 |
+
"sigmoid_scale": false,
|
| 176 |
+
"d_vector_dim": 0,
|
| 177 |
+
"data_dep_init_steps": 10,
|
| 178 |
+
"style_wav_for_test": null,
|
| 179 |
+
"length_scale": 1.0,
|
| 180 |
+
"use_speaker_embedding": false,
|
| 181 |
+
"speakers_file": null,
|
| 182 |
+
"use_d_vector_file": false,
|
| 183 |
+
"d_vector_file": false,
|
| 184 |
+
"min_seq_len": 3,
|
| 185 |
+
"max_seq_len": 500,
|
| 186 |
+
"r": 1,
|
| 187 |
+
"restore_path": "/kaggle/working/train_output/run-December-24-2022_09+28AM-0000000/checkpoint_40000.pth",
|
| 188 |
+
"github_branch": "inside_docker"
|
| 189 |
+
}
|
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
|