|
import os
|
|
|
|
|
|
|
|
from trainer import Trainer, TrainerArgs
|
|
|
|
|
|
from TTS.tts.configs.glow_tts_config import GlowTTSConfig
|
|
|
|
|
|
from TTS.tts.configs.shared_configs import BaseAudioConfig, BaseDatasetConfig, CharactersConfig
|
|
from TTS.tts.datasets import load_tts_samples
|
|
from TTS.tts.models.glow_tts import GlowTTS
|
|
from TTS.tts.utils.text.tokenizer import TTSTokenizer
|
|
from TTS.utils.audio import AudioProcessor
|
|
|
|
|
|
output_path = "/storage/output-glowtts/"
|
|
|
|
|
|
|
|
|
|
|
|
dataset_config = BaseDatasetConfig(
|
|
formatter="bel_tts_formatter",
|
|
meta_file_train="ipa_final_dataset.csv",
|
|
path=os.path.join(output_path, "/storage/filtered_dataset/"),
|
|
)
|
|
|
|
characters = CharactersConfig(
|
|
characters_class="TTS.tts.utils.text.characters.Graphemes",
|
|
pad="_",
|
|
eos="~",
|
|
bos="^",
|
|
blank="@",
|
|
characters="Iabdfgijklmnprstuvxzɔɛɣɨɫɱʂʐʲˈː̯͡β",
|
|
punctuations="!,.?: -‒–—…",
|
|
)
|
|
|
|
audio_config = BaseAudioConfig(
|
|
mel_fmin=50,
|
|
mel_fmax=8000,
|
|
hop_length=256,
|
|
stats_path="/storage/TTS/scale_stats.npy",
|
|
)
|
|
|
|
|
|
|
|
config = GlowTTSConfig(
|
|
batch_size=96,
|
|
eval_batch_size=32,
|
|
num_loader_workers=8,
|
|
num_eval_loader_workers=8,
|
|
use_noise_augment=True,
|
|
run_eval=True,
|
|
test_delay_epochs=-1,
|
|
epochs=1000,
|
|
print_step=50,
|
|
print_eval=True,
|
|
output_path=output_path,
|
|
add_blank=True,
|
|
datasets=[dataset_config],
|
|
|
|
enable_eos_bos_chars=True,
|
|
mixed_precision=False,
|
|
save_step=10000,
|
|
save_n_checkpoints=2,
|
|
save_best_after=5000,
|
|
text_cleaner="no_cleaners",
|
|
audio=audio_config,
|
|
test_sentences=[],
|
|
use_phonemes=True,
|
|
phoneme_language="be",
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
|
|
ap = AudioProcessor.init_from_config(config)
|
|
|
|
|
|
|
|
|
|
tokenizer, config = TTSTokenizer.init_from_config(config)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
train_samples, eval_samples = load_tts_samples(
|
|
dataset_config,
|
|
eval_split=True,
|
|
eval_split_max_size=config.eval_split_max_size,
|
|
eval_split_size=config.eval_split_size,
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
model = GlowTTS(config, ap, tokenizer, speaker_manager=None)
|
|
|
|
|
|
|
|
|
|
trainer = Trainer(
|
|
TrainerArgs(), config, output_path, model=model, train_samples=train_samples, eval_samples=eval_samples
|
|
)
|
|
|
|
|
|
trainer.fit()
|
|
|