未验证 提交 ad7f01d5 编写于 作者: B blue-fish 提交者: GitHub

Print helpful error message if models not found (#416)

上级 6edc39eb
from encoder.params_model import model_embedding_size as speaker_embedding_size
from utils.argutils import print_args
from utils.modelutils import check_model_paths
from synthesizer.inference import Synthesizer
from encoder import inference as encoder
from vocoder import inference as vocoder
......@@ -53,6 +54,9 @@ if __name__ == '__main__':
else:
print("Using CPU for inference.\n")
## Remind the user to download pretrained models if needed
check_model_paths(encoder_path=args.enc_model_fpath, synthesizer_path=args.syn_model_dir,
vocoder_path=args.voc_model_fpath)
## Load the models one by one.
print("Preparing the encoder, the synthesizer and the vocoder...")
......
from pathlib import Path
from toolbox import Toolbox
from utils.argutils import print_args
from utils.modelutils import check_model_paths
import argparse
......@@ -26,8 +27,11 @@ if __name__ == '__main__':
"If True, the memory used by the synthesizer will be freed after each use. Adds large "
"overhead but allows to save some GPU memory for lower-end GPUs.")
args = parser.parse_args()
print_args(args, parser)
## Remind the user to download pretrained models if needed
check_model_paths(encoder_path=args.enc_models_dir, synthesizer_path=args.syn_models_dir,
vocoder_path=args.voc_models_dir)
# Launch the toolbox
print_args(args, parser)
Toolbox(**vars(args))
\ No newline at end of file
Toolbox(**vars(args))
from pathlib import Path
def check_model_paths(encoder_path: Path, synthesizer_path: Path, vocoder_path: Path):
# This function tests the model paths and makes sure at least one is valid.
if encoder_path.is_file() or encoder_path.is_dir():
return
if synthesizer_path.is_file() or synthesizer_path.is_dir():
return
if vocoder_path.is_file() or vocoder_path.is_dir():
return
# If none of the paths exist, remind the user to download models if needed
print("Error: Model files not found. If needed, download them here:")
print("https://github.com/CorentinJ/Real-Time-Voice-Cloning/wiki/Pretrained-models\n")
quit(-1)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册