From 0a92f23a2300b911dfa5f05bf58b45c3668f4c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eren=20G=C3=B6lge?= Date: Wed, 5 Jul 2023 12:04:10 +0200 Subject: [PATCH] Squashed commit of the following: commit dd612fd72e0ab698239e832a4b73a6e695c6e5e6 Author: JiangCheng Date: Mon Jun 5 16:04:54 2023 +0800 Failed to download the file and need to delete the created file path --- TTS/utils/manage.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/TTS/utils/manage.py b/TTS/utils/manage.py index 354e193ac8..29bdb24ae2 100644 --- a/TTS/utils/manage.py +++ b/TTS/utils/manage.py @@ -317,14 +317,19 @@ def download_model(self, model_name): else: os.makedirs(output_path, exist_ok=True) print(f" > Downloading model to {output_path}") - if "fairseq" in model_name: - self.download_fairseq_model(model_name, output_path) - elif "github_rls_url" in model_item: - self._download_github_model(model_item, output_path) - elif "hf_url" in model_item: - self._download_hf_model(model_item, output_path) - - self.print_model_license(model_item=model_item) + try: + if "fairseq" in model_name: + self.download_fairseq_model(model_name, output_path) + elif "github_rls_url" in model_item: + self._download_github_model(model_item, output_path) + elif "hf_url" in model_item: + self._download_hf_model(model_item, output_path) + + except requests.Exception.RequestException as e: + print(f" > Failed to download the model file to {output_path}") + rmtree(output_path) + raise e + self.print_model_license(model_item=model_item) # find downloaded files output_model_path = output_path output_config_path = None