Skip to content

Commit

Permalink
Update synthesize.py
Browse files Browse the repository at this point in the history
1) added Win10 pickle fix per issue CorentinJ#669 and blue-fish/Real-Time-Voice-Cloning@89a9964 (lines 12 and 70)
2) edited line 19 to delete "hparams" as argument; hparams_debug_string() needs 0 arguments. Allows vocoder_preprocess.py to run properly on WIn10/GPU (CUDA) systems)
3) edited line 87 to fix improper definition for mels_out per @blue-fish recommendation in issue#729 and issue CorentinJ#833; Allows vocoder_preprocess.py to run properly on WIn10/GPU (CUDA) systems)
  • Loading branch information
Tomcattwo authored Sep 1, 2021
1 parent a5a4c48 commit ac46da5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions synthesizer/synthesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import numpy as np
from pathlib import Path
from tqdm import tqdm

#@tomcattwo added below line to fix Win10 pickle error per issue #669 and blue-fish/Real-Time-Voice-Cloning@89a9964
import platform

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))
#@tomcattwo edited below line to remove argument "hparams" from "hparams_debug_string(hparams)" to fix error when running vocoder_preprocess (issue #833)
print(hparams_debug_string())

# Check for GPU
if torch.cuda.is_available():
Expand Down Expand Up @@ -60,11 +62,12 @@ def run_synthesis(in_dir, out_dir, model_dir, hparams):
mel_dir = in_dir.joinpath("mels")
embed_dir = in_dir.joinpath("embeds")

#@tomcattwo edited line 67 to add "hparams" positional argument per issue #833 and line 69 to fix Win10 pickle issue per issue#669 and blue-fish/Real-Time-Voice-Cloning@89a9964
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, r, hparams),
batch_size=hparams.synthesis_batch_size,
num_workers=2,
num_workers=2 if platform.system() != "Windows" else 0,
shuffle=False,
pin_memory=True)

Expand All @@ -77,11 +80,12 @@ def run_synthesis(in_dir, out_dir, model_dir, hparams):
embeds = embeds.to(device)

# Parallelize model onto GPUS using workaround due to python bug
#@tomcattwo edited line 86 per @blue-fish recommendation in issue #833 to allow vocoder_preprocess.py to run properly
if device.type == "cuda" and torch.cuda.device_count() > 1:
_, 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
mel_filename = Path(synth_dir).joinpath(dataset.metadata[k][1])
Expand Down

0 comments on commit ac46da5

Please sign in to comment.