Rename converted to wavs for TTS training format. Add script to repeat metadata.csv column for ljspeech format.
parent
e61dccf52e
commit
733afa7f45
@ -0,0 +1,23 @@
|
||||
import pyjson5
|
||||
import os
|
||||
|
||||
CUR_DIR = os.getcwd()
|
||||
|
||||
with open("./example-config.json") as input_f:
|
||||
with open("./config.json", "w") as output_f:
|
||||
lines = input_f.readlines()
|
||||
data = ''.join(lines)
|
||||
obj = pyjson5.loads(data)
|
||||
|
||||
audio = obj["audio"]
|
||||
audio["stats_path"] = os.path.join(CUR_DIR, 'scale_stats.npy' )
|
||||
|
||||
#output_path = obj['output_path']
|
||||
obj["output_path"] = os.path.join(CUR_DIR, 'models', 'LJSpeech')
|
||||
|
||||
#phoneme_path = obj['phoneme_cache_path']
|
||||
obj["phoneme_cache_path"] = os.path.join(CUR_DIR, 'models', 'phoneme_cache')
|
||||
|
||||
obj["datasets"][0]["path"] = os.path.join(CUR_DIR)
|
||||
|
||||
output_f.write(pyjson5.dumps(obj))
|
||||
@ -0,0 +1,15 @@
|
||||
import os
|
||||
|
||||
CUR_DIR = os.getcwd()
|
||||
|
||||
with open("./example-metadata.csv") as input_f:
|
||||
with open("./metadata.csv", "w") as output_f:
|
||||
lines = input_f.readlines()
|
||||
write_lines = []
|
||||
|
||||
for line in lines:
|
||||
cols = line.split('|')
|
||||
cols.append(cols[1]) # repeat col[1] to be col[2] for the ljspeech format
|
||||
write_lines.append('|'.join(cols))
|
||||
|
||||
output_f.write('\n'.join(write_lines))
|
||||
@ -0,0 +1,2 @@
|
||||
TTS
|
||||
pyjson5
|
||||
@ -0,0 +1,106 @@
|
||||
import os
|
||||
|
||||
from trainer import Trainer, TrainerArgs
|
||||
|
||||
from TTS.config.shared_configs import BaseAudioConfig
|
||||
from TTS.tts.configs.shared_configs import BaseDatasetConfig
|
||||
from TTS.tts.configs.tacotron2_config import Tacotron2Config
|
||||
from TTS.tts.datasets import load_tts_samples
|
||||
from TTS.tts.models.tacotron2 import Tacotron2
|
||||
from TTS.tts.utils.text.tokenizer import TTSTokenizer
|
||||
from TTS.utils.audio import AudioProcessor
|
||||
|
||||
# from TTS.tts.datasets.tokenizer import Tokenizer
|
||||
|
||||
output_path = "."
|
||||
|
||||
# init configs
|
||||
dataset_config = BaseDatasetConfig(
|
||||
formatter="mailabs",
|
||||
dataset_name="ljspeech", meta_file_train="metadata.csv",
|
||||
path=output_path # os.path.join(output_path, "/content/LJSpeech-1.1")
|
||||
)
|
||||
|
||||
print(str(dataset_config))
|
||||
|
||||
audio_config = BaseAudioConfig(
|
||||
sample_rate=22050,
|
||||
do_trim_silence=True,
|
||||
trim_db=60.0,
|
||||
signal_norm=False,
|
||||
mel_fmin=0.0,
|
||||
mel_fmax=8000,
|
||||
spec_gain=1.0,
|
||||
log_func="np.log",
|
||||
ref_level_db=20,
|
||||
preemphasis=0.0,
|
||||
)
|
||||
|
||||
config = Tacotron2Config( # This is the config that is saved for the future use
|
||||
audio=audio_config,
|
||||
batch_size=64,
|
||||
eval_batch_size=16,
|
||||
num_loader_workers=4,
|
||||
num_eval_loader_workers=4,
|
||||
run_eval=True,
|
||||
test_delay_epochs=-1,
|
||||
ga_alpha=0.0,
|
||||
decoder_loss_alpha=0.25,
|
||||
postnet_loss_alpha=0.25,
|
||||
postnet_diff_spec_alpha=0,
|
||||
decoder_diff_spec_alpha=0,
|
||||
decoder_ssim_alpha=0,
|
||||
postnet_ssim_alpha=0,
|
||||
r=2,
|
||||
attention_type="dynamic_convolution",
|
||||
double_decoder_consistency=False,
|
||||
epochs=1000,
|
||||
text_cleaner="phoneme_cleaners",
|
||||
use_phonemes=True,
|
||||
phoneme_language="en-us",
|
||||
phoneme_cache_path=os.path.join(output_path, "phoneme_cache"),
|
||||
print_step=25,
|
||||
print_eval=True,
|
||||
mixed_precision=False,
|
||||
output_path=output_path,
|
||||
datasets=[dataset_config],
|
||||
)
|
||||
|
||||
# INITIALIZE THE AUDIO PROCESSOR
|
||||
# Audio processor is used for feature extraction and audio I/O.
|
||||
# It mainly serves to the dataloader and the training loggers.
|
||||
ap = AudioProcessor.init_from_config(config)
|
||||
|
||||
# INITIALIZE THE TOKENIZER
|
||||
# Tokenizer is used to convert text to sequences of token IDs.
|
||||
# If characters are not defined in the config, default characters are passed to the config
|
||||
tokenizer, config = TTSTokenizer.init_from_config(config)
|
||||
|
||||
# LOAD DATA SAMPLES
|
||||
# Each sample is a list of ```[text, audio_file_path, speaker_name]```
|
||||
# You can define your custom sample loader returning the list of samples.
|
||||
# Or define your custom formatter and pass it to the `load_tts_samples`.
|
||||
# Check `TTS.tts.datasets.load_tts_samples` for more details.
|
||||
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,
|
||||
)
|
||||
|
||||
# INITIALIZE THE MODEL
|
||||
# Models take a config object and a speaker manager as input
|
||||
# Config defines the details of the model like the number of layers, the size of the embedding, etc.
|
||||
# Speaker manager is used by multi-speaker models.
|
||||
model = Tacotron2(config, ap, tokenizer)
|
||||
|
||||
# INITIALIZE THE TRAINER
|
||||
# Trainer provides a generic API to train all the 🐸TTS models with all its perks like mixed-precision training,
|
||||
# distributed training, etc.
|
||||
trainer = Trainer(
|
||||
TrainerArgs(), config, output_path, model=model, train_samples=train_samples, eval_samples=eval_samples
|
||||
)
|
||||
|
||||
# AND... 3,2,1... 🚀
|
||||
trainer.fit()
|
||||
|
||||
Loading…
Reference in new issue