From 3e5ce85bf7b4d84575632908c962151b355a6a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 13 Jun 2020 19:34:26 +0100 Subject: [PATCH] load ParallelWaveGAN from PYTHONPATH if pwgan_lib_path is unset --- server/synthesizer.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/server/synthesizer.py b/server/synthesizer.py index 392dcc4a..c6fde902 100644 --- a/server/synthesizer.py +++ b/server/synthesizer.py @@ -37,7 +37,7 @@ class Synthesizer(object): if self.config.wavernn_lib_path: self.load_wavernn(self.config.wavernn_lib_path, self.config.wavernn_file, self.config.wavernn_config, self.config.use_cuda) - if self.config.pwgan_lib_path: + if self.config.pwgan_file: self.load_pwgan(self.config.pwgan_lib_path, self.config.pwgan_file, self.config.pwgan_config, self.config.use_cuda) @@ -113,9 +113,14 @@ class Synthesizer(object): self.wavernn.eval() def load_pwgan(self, lib_path, model_file, model_config, use_cuda): - sys.path.append(lib_path) # set this if ParallelWaveGAN is not installed globally - #pylint: disable=import-outside-toplevel - from parallel_wavegan.models import ParallelWaveGANGenerator + if lib_path: + # set this if ParallelWaveGAN is not installed globally + sys.path.append(lib_path) + try: + #pylint: disable=import-outside-toplevel + from parallel_wavegan.models import ParallelWaveGANGenerator + except ImportError as e: + raise RuntimeError(f"cannot import parallel-wavegan, either install it or set its directory using the --pwgan_lib_path command line argument: {e}") print(" > Loading PWGAN model ...") print(" | > model config: ", model_config) print(" | > model file: ", model_file)