Spaces:
Runtime error
Runtime error
Upload vocoder_train.py with huggingface_hub
Browse files- vocoder_train.py +56 -0
vocoder_train.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from utils.argutils import print_args
|
2 |
+
from vocoder.train import train
|
3 |
+
from pathlib import Path
|
4 |
+
import argparse
|
5 |
+
|
6 |
+
|
7 |
+
if __name__ == "__main__":
|
8 |
+
parser = argparse.ArgumentParser(
|
9 |
+
description="Trains the vocoder from the synthesizer audios and the GTA synthesized mels, "
|
10 |
+
"or ground truth mels.",
|
11 |
+
formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
12 |
+
)
|
13 |
+
|
14 |
+
parser.add_argument("run_id", type=str, help= \
|
15 |
+
"Name for this model instance. If a model state from the same run ID was previously "
|
16 |
+
"saved, the training will restart from there. Pass -f to overwrite saved states and "
|
17 |
+
"restart from scratch.")
|
18 |
+
parser.add_argument("datasets_root", type=str, help= \
|
19 |
+
"Path to the directory containing your SV2TTS directory. Specifying --syn_dir or --voc_dir "
|
20 |
+
"will take priority over this argument.")
|
21 |
+
parser.add_argument("--syn_dir", type=str, default=argparse.SUPPRESS, help= \
|
22 |
+
"Path to the synthesizer directory that contains the ground truth mel spectrograms, "
|
23 |
+
"the wavs and the embeds. Defaults to <datasets_root>/SV2TTS/synthesizer/.")
|
24 |
+
parser.add_argument("--voc_dir", type=str, default=argparse.SUPPRESS, help= \
|
25 |
+
"Path to the vocoder directory that contains the GTA synthesized mel spectrograms. "
|
26 |
+
"Defaults to <datasets_root>/SV2TTS/vocoder/. Unused if --ground_truth is passed.")
|
27 |
+
parser.add_argument("-m", "--models_dir", type=str, default="vocoder/saved_models/", help=\
|
28 |
+
"Path to the directory that will contain the saved model weights, as well as backups "
|
29 |
+
"of those weights and wavs generated during training.")
|
30 |
+
parser.add_argument("-g", "--ground_truth", action="store_true", help= \
|
31 |
+
"Train on ground truth spectrograms (<datasets_root>/SV2TTS/synthesizer/mels).")
|
32 |
+
parser.add_argument("-s", "--save_every", type=int, default=1000, help= \
|
33 |
+
"Number of steps between updates of the model on the disk. Set to 0 to never save the "
|
34 |
+
"model.")
|
35 |
+
parser.add_argument("-b", "--backup_every", type=int, default=25000, help= \
|
36 |
+
"Number of steps between backups of the model. Set to 0 to never make backups of the "
|
37 |
+
"model.")
|
38 |
+
parser.add_argument("-f", "--force_restart", action="store_true", help= \
|
39 |
+
"Do not load any saved model and restart from scratch.")
|
40 |
+
args = parser.parse_args()
|
41 |
+
|
42 |
+
# Process the arguments
|
43 |
+
if not hasattr(args, "syn_dir"):
|
44 |
+
args.syn_dir = Path(args.datasets_root, "SV2TTS", "synthesizer")
|
45 |
+
args.syn_dir = Path(args.syn_dir)
|
46 |
+
if not hasattr(args, "voc_dir"):
|
47 |
+
args.voc_dir = Path(args.datasets_root, "SV2TTS", "vocoder")
|
48 |
+
args.voc_dir = Path(args.voc_dir)
|
49 |
+
del args.datasets_root
|
50 |
+
args.models_dir = Path(args.models_dir)
|
51 |
+
args.models_dir.mkdir(exist_ok=True)
|
52 |
+
|
53 |
+
# Run the training
|
54 |
+
print_args(args, parser)
|
55 |
+
train(**vars(args))
|
56 |
+
|