def preprocess(experiment: Experiment, args: Mapping) -> None: """ Preprocesses wavs and text, returns None or raises an Exception. """ # bring data in format usable by Tacotron-2 # for now just copy them over raw_wav_dir = os.path.join(experiment.paths["acoustic_model"], "LJSpeech-1.1", "wavs") fu.ensure_dir(raw_wav_dir) fu.copy_files(args["wav_dir"], raw_wav_dir) raw_metadata_file = os.path.join(experiment.paths["acoustic_model"], "LJSpeech-1.1", "metadata.csv") fu.copy_file(args["text_file"], raw_metadata_file) # run Tacotron-2 preprocessing tacoargs = namedtuple( "tacoargs", "base_dir hparams dataset language voice reader merge_books book output n_jobs" .split()) tacoargs.base_dir = experiment.paths["acoustic_model"] tacoargs.language = experiment.config["language"] tacoargs.output = experiment.paths["acoustic_features"] tacoargs.hparams = "" tacoargs.n_jobs = multiprocessing.cpu_count() # for now we always exploit the LJ settings tacoargs.dataset = "LJSpeech-1.1" tacoargs.voice = "female" tacoargs.reader = "LJ" tacoargs.merge_books = "True" tacoargs.book = "northandsouth" modified_hp = tacotron2.hparams.hparams.parse(tacoargs.hparams) tacotron2.preprocess.run_preprocess(tacoargs, modified_hp)
def generate(experiment: Experiment, sentences, generate_features: bool = True, generate_waveforms: bool = True) -> None: """ Generates from the model. :param Experiment experiment: The experiment to generate from. :param bool generate_features: Store acoustic features :param bool generate_waveforms: Generate a waveform from acoustic features using Griffin-Lim """ # python synthesize.py --model Tacotron --tacotron_name Tacotron-2 --mode eval --text_list text_list.txt &> /dev/null tacoargs = namedtuple( "tacoargs", "mode model checkpoint output_dir mels_dir hparams name tacotron_name GTA" .split()) tacoargs.checkpoint = _get_pretrained_folder(experiment) tacoargs.hparams = '' tacoargs.name = "Tacotron" tacoargs.tacotron_name = "Tacotron" tacoargs.model = "Tacotron" #tacoargs.input_dir = 'training_data/' tacoargs.mels_dir = experiment.paths["acoustic2wavegen_features"] tacoargs.output_dir = experiment.paths["acoustic2wavegen_features"] tacoargs.mode = "eval" tacoargs.GTA = False #tacoargs.base_dir = '' #tacoargs.log_dir = None #taco_checkpoint, _, hparams = tacotron2.synthesize.prepare_run(tacoargs) modified_hp = tacotron2.hparams.hparams.parse(tacoargs.hparams) #taco_checkpoint = os.path.join("tacotron2", taco_checkpoint) tacotron2.tacotron.synthesize.tacotron_synthesize(tacoargs, modified_hp, tacoargs.checkpoint, sentences) output_dir = os.path.join(experiment.paths["synthesized_wavs"], "griffinlim") fu.ensure_dir(output_dir) fu.copy_files( os.path.join(experiment.paths["acoustic2wavegen_features"], "logs-eval", "wavs"), output_dir)