Spaces:
Runtime error
Runtime error
Upload demo_toolbox.py with huggingface_hub
Browse files- demo_toolbox.py +43 -0
demo_toolbox.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pathlib import Path
|
2 |
+
from toolbox import Toolbox
|
3 |
+
from utils.argutils import print_args
|
4 |
+
from utils.modelutils import check_model_paths
|
5 |
+
import argparse
|
6 |
+
import os
|
7 |
+
|
8 |
+
|
9 |
+
if __name__ == '__main__':
|
10 |
+
parser = argparse.ArgumentParser(
|
11 |
+
description="Runs the toolbox",
|
12 |
+
formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
13 |
+
)
|
14 |
+
|
15 |
+
parser.add_argument("-d", "--datasets_root", type=Path, help= \
|
16 |
+
"Path to the directory containing your datasets. See toolbox/__init__.py for a list of "
|
17 |
+
"supported datasets.", default=None)
|
18 |
+
parser.add_argument("-e", "--enc_models_dir", type=Path, default="encoder/saved_models",
|
19 |
+
help="Directory containing saved encoder models")
|
20 |
+
parser.add_argument("-s", "--syn_models_dir", type=Path, default="synthesizer/saved_models",
|
21 |
+
help="Directory containing saved synthesizer models")
|
22 |
+
parser.add_argument("-v", "--voc_models_dir", type=Path, default="vocoder/saved_models",
|
23 |
+
help="Directory containing saved vocoder models")
|
24 |
+
parser.add_argument("--cpu", action="store_true", help=\
|
25 |
+
"If True, processing is done on CPU, even when a GPU is available.")
|
26 |
+
parser.add_argument("--seed", type=int, default=None, help=\
|
27 |
+
"Optional random number seed value to make toolbox deterministic.")
|
28 |
+
parser.add_argument("--no_mp3_support", action="store_true", help=\
|
29 |
+
"If True, no mp3 files are allowed.")
|
30 |
+
args = parser.parse_args()
|
31 |
+
print_args(args, parser)
|
32 |
+
|
33 |
+
if args.cpu:
|
34 |
+
# Hide GPUs from Pytorch to force CPU processing
|
35 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
|
36 |
+
del args.cpu
|
37 |
+
|
38 |
+
## Remind the user to download pretrained models if needed
|
39 |
+
check_model_paths(encoder_path=args.enc_models_dir, synthesizer_path=args.syn_models_dir,
|
40 |
+
vocoder_path=args.voc_models_dir)
|
41 |
+
|
42 |
+
# Launch the toolbox
|
43 |
+
Toolbox(**vars(args))
|