|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
import torch
|
|
|
|
|
from torch.utils.data import DataLoader
|
|
|
|
|
from synthesizer.hparams import hparams_debug_string
|
|
|
|
|
from synthesizer.synthesizer_dataset import SynthesizerDataset, collate_synthesizer
|
|
|
|
|
from synthesizer.models.tacotron import Tacotron
|
|
|
|
|
from synthesizer.utils.text import text_to_sequence
|
|
|
|
@ -8,13 +7,14 @@ from synthesizer.utils.symbols import symbols
|
|
|
|
|
import numpy as np
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
from tqdm import tqdm
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_synthesis(in_dir, out_dir, model_dir, hparams):
|
|
|
|
|
# This generates ground truth-aligned mels for vocoder training
|
|
|
|
|
synth_dir = Path(out_dir).joinpath("mels_gta")
|
|
|
|
|
synth_dir.mkdir(exist_ok=True)
|
|
|
|
|
print(hparams_debug_string(hparams))
|
|
|
|
|
synth_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
print(str(hparams))
|
|
|
|
|
|
|
|
|
|
# Check for GPU
|
|
|
|
|
if torch.cuda.is_available():
|
|
|
|
@ -59,12 +59,12 @@ def run_synthesis(in_dir, out_dir, model_dir, hparams):
|
|
|
|
|
metadata_fpath = in_dir.joinpath("train.txt")
|
|
|
|
|
mel_dir = in_dir.joinpath("mels")
|
|
|
|
|
embed_dir = in_dir.joinpath("embeds")
|
|
|
|
|
|
|
|
|
|
num_workers = 0 if sys.platform.startswith("win") else 2;
|
|
|
|
|
dataset = SynthesizerDataset(metadata_fpath, mel_dir, embed_dir, hparams)
|
|
|
|
|
data_loader = DataLoader(dataset,
|
|
|
|
|
collate_fn=lambda batch: collate_synthesizer(batch, r),
|
|
|
|
|
collate_fn=lambda batch: collate_synthesizer(batch),
|
|
|
|
|
batch_size=hparams.synthesis_batch_size,
|
|
|
|
|
num_workers=2,
|
|
|
|
|
num_workers=num_workers,
|
|
|
|
|
shuffle=False,
|
|
|
|
|
pin_memory=True)
|
|
|
|
|
|
|
|
|
@ -78,9 +78,9 @@ def run_synthesis(in_dir, out_dir, model_dir, hparams):
|
|
|
|
|
|
|
|
|
|
# Parallelize model onto GPUS using workaround due to python bug
|
|
|
|
|
if device.type == "cuda" and torch.cuda.device_count() > 1:
|
|
|
|
|
_, mels_out, _ = data_parallel_workaround(model, texts, mels, embeds)
|
|
|
|
|
_, mels_out, _ , _ = data_parallel_workaround(model, texts, mels, embeds)
|
|
|
|
|
else:
|
|
|
|
|
_, mels_out, _ = model(texts, mels, embeds)
|
|
|
|
|
_, mels_out, _, _ = model(texts, mels, embeds)
|
|
|
|
|
|
|
|
|
|
for j, k in enumerate(idx):
|
|
|
|
|
# Note: outputs mel-spectrogram files and target ones have same names, just different folders
|
|
|
|
|