|
import os |
|
|
|
from TTS.encoder.configs.speaker_encoder_config import SpeakerEncoderConfig |
|
|
|
|
|
from TTS.tts.configs.shared_configs import BaseDatasetConfig |
|
|
|
CURRENT_PATH = os.getcwd() |
|
|
|
os.chdir("../../../") |
|
|
|
|
|
|
|
VCTK_PATH = "/raid/datasets/VCTK_NEW_16khz_removed_silence_silero_vad/" |
|
RIR_SIMULATED_PATH = "/raid/datasets/DA/RIRS_NOISES/simulated_rirs/" |
|
MUSAN_PATH = "/raid/datasets/DA/musan/" |
|
|
|
|
|
OUTPUT_PATH = os.path.join( |
|
CURRENT_PATH, "resnet_speaker_encoder_training_output/" |
|
) |
|
CONFIG_OUT_PATH = os.path.join(OUTPUT_PATH, "config_se.json") |
|
RESTORE_PATH = None |
|
|
|
|
|
|
|
config = SpeakerEncoderConfig() |
|
|
|
|
|
|
|
|
|
|
|
|
|
dataset_config = BaseDatasetConfig(formatter="vctk", meta_file_train="", language="en-us", path=VCTK_PATH) |
|
|
|
|
|
config.datasets = [dataset_config] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.num_classes_in_batch = 100 |
|
|
|
config.num_utter_per_class = 4 |
|
|
|
|
|
|
|
config.eval_num_classes_in_batch = 100 |
|
|
|
config.eval_num_utter_per_class = 4 |
|
|
|
|
|
config.num_loader_workers = 8 |
|
config.num_val_loader_workers = 8 |
|
|
|
|
|
config.epochs = 10000 |
|
|
|
config.loss = "softmaxproto" |
|
|
|
|
|
config.run_eval = False |
|
|
|
|
|
config.output_path = OUTPUT_PATH |
|
|
|
|
|
config.save_step = 2000 |
|
|
|
|
|
config.model_params = { |
|
"model_name": "resnet", |
|
"input_dim": 64, |
|
"use_torch_spec": True, |
|
"log_input": True, |
|
"proj_dim": 512, |
|
} |
|
|
|
|
|
|
|
config.voice_len = 2.0 |
|
|
|
config.audio = { |
|
"fft_size": 512, |
|
"win_length": 400, |
|
"hop_length": 160, |
|
"frame_shift_ms": None, |
|
"frame_length_ms": None, |
|
"stft_pad_mode": "reflect", |
|
"sample_rate": 16000, |
|
"resample": False, |
|
"preemphasis": 0.97, |
|
"ref_level_db": 20, |
|
"do_sound_norm": False, |
|
"do_trim_silence": False, |
|
"trim_db": 60, |
|
"power": 1.5, |
|
"griffin_lim_iters": 60, |
|
"num_mels": 64, |
|
"mel_fmin": 0.0, |
|
"mel_fmax": 8000.0, |
|
"spec_gain": 20, |
|
"signal_norm": False, |
|
"min_level_db": -100, |
|
"symmetric_norm": False, |
|
"max_norm": 4.0, |
|
"clip_norm": False, |
|
"stats_path": None, |
|
"do_rms_norm": True, |
|
"db_level": -27.0, |
|
} |
|
|
|
|
|
|
|
config.audio_augmentation = { |
|
|
|
"p": 0.5, |
|
"rir": {"rir_path": RIR_SIMULATED_PATH, "conv_mode": "full"}, |
|
"additive": { |
|
"sounds_path": MUSAN_PATH, |
|
"speech": {"min_snr_in_db": 13, "max_snr_in_db": 20, "min_num_noises": 1, "max_num_noises": 1}, |
|
"noise": {"min_snr_in_db": 0, "max_snr_in_db": 15, "min_num_noises": 1, "max_num_noises": 1}, |
|
"music": {"min_snr_in_db": 5, "max_snr_in_db": 15, "min_num_noises": 1, "max_num_noises": 1}, |
|
}, |
|
"gaussian": {"p": 0.7, "min_amplitude": 0.0, "max_amplitude": 1e-05}, |
|
} |
|
|
|
config.save_json(CONFIG_OUT_PATH) |
|
|
|
print(CONFIG_OUT_PATH) |
|
if RESTORE_PATH is not None: |
|
command = f"python TTS/bin/train_encoder.py --config_path {CONFIG_OUT_PATH} --restore_path {RESTORE_PATH}" |
|
else: |
|
command = f"python TTS/bin/train_encoder.py --config_path {CONFIG_OUT_PATH}" |
|
|
|
os.system(command) |
|
|