mirror of https://github.com/coqui-ai/TTS.git
Try-except to present error when the user dont have connection
This commit is contained in:
parent
529ea3f67f
commit
99650044a4
|
@ -343,6 +343,24 @@ class ModelManager(object):
|
||||||
raise e
|
raise e
|
||||||
self.print_model_license(model_item=model_item)
|
self.print_model_license(model_item=model_item)
|
||||||
|
|
||||||
|
def check_if_configs_are_equal(self, model_name, model_item, output_path):
|
||||||
|
with fsspec.open(self._find_files(output_path)[1], "r", encoding="utf-8") as f:
|
||||||
|
config_local = json.load(f)
|
||||||
|
remote_url = None
|
||||||
|
for url in model_item["hf_url"]:
|
||||||
|
if "config.json" in url:
|
||||||
|
remote_url = url
|
||||||
|
break
|
||||||
|
|
||||||
|
with fsspec.open(remote_url, "r", encoding="utf-8") as f:
|
||||||
|
config_remote = json.load(f)
|
||||||
|
|
||||||
|
if not config_local == config_remote:
|
||||||
|
print(f" > {model_name} is already downloaded however it has been changed. Redownloading it...")
|
||||||
|
self.create_dir_and_download_model(model_name, model_item, output_path)
|
||||||
|
else:
|
||||||
|
print(f" > {model_name} is already downloaded.")
|
||||||
|
|
||||||
def download_model(self, model_name):
|
def download_model(self, model_name):
|
||||||
"""Download model files given the full model name.
|
"""Download model files given the full model name.
|
||||||
Model name is in the format
|
Model name is in the format
|
||||||
|
@ -364,22 +382,10 @@ class ModelManager(object):
|
||||||
# if the configs are different, redownload it
|
# if the configs are different, redownload it
|
||||||
# ToDo: we need a better way to handle it
|
# ToDo: we need a better way to handle it
|
||||||
if "xtts_v1" in model_name:
|
if "xtts_v1" in model_name:
|
||||||
with fsspec.open(self._find_files(output_path)[1], "r", encoding="utf-8") as f:
|
try:
|
||||||
config_local = json.load(f)
|
self.check_if_configs_are_equal(model_name, model_item, output_path)
|
||||||
remote_url = None
|
except:
|
||||||
for url in model_item["hf_url"]:
|
pass
|
||||||
if "config.json" in url:
|
|
||||||
remote_url = url
|
|
||||||
break
|
|
||||||
|
|
||||||
with fsspec.open(remote_url, "r", encoding="utf-8") as f:
|
|
||||||
config_remote = json.load(f)
|
|
||||||
|
|
||||||
if not config_local == config_remote:
|
|
||||||
print(f" > {model_name} is already downloaded however it has been changed. Redownloading it...")
|
|
||||||
self.create_dir_and_download_model(model_name, model_item, output_path)
|
|
||||||
else:
|
|
||||||
print(f" > {model_name} is already downloaded.")
|
|
||||||
else:
|
else:
|
||||||
print(f" > {model_name} is already downloaded.")
|
print(f" > {model_name} is already downloaded.")
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue