From 88485d9e67a02aa2909afaaf0c657047f04929f2 Mon Sep 17 00:00:00 2001 From: Enno Hermann Date: Fri, 10 Jan 2025 18:19:02 +0100 Subject: [PATCH] fix(bark): handle broken paths in config (#253) --- TTS/tts/layers/bark/load_model.py | 4 +++- TTS/tts/models/bark.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/TTS/tts/layers/bark/load_model.py b/TTS/tts/layers/bark/load_model.py index 6b7caab916..c1e0d006cb 100644 --- a/TTS/tts/layers/bark/load_model.py +++ b/TTS/tts/layers/bark/load_model.py @@ -112,7 +112,9 @@ def load_model(ckpt_path, device, config, model_type="text"): os.remove(ckpt_path) if not os.path.exists(ckpt_path): logger.info(f"{model_type} model not found, downloading...") - _download(config.REMOTE_MODEL_PATHS[model_type]["path"], ckpt_path, config.CACHE_DIR) + # The URL in the config is a 404 and needs to be fixed + download_url = config.REMOTE_MODEL_PATHS[model_type]["path"].replace("tree", "resolve") + _download(download_url, ckpt_path, config.CACHE_DIR) checkpoint = torch.load(ckpt_path, map_location=device, weights_only=is_pytorch_at_least_2_4()) # this is a hack diff --git a/TTS/tts/models/bark.py b/TTS/tts/models/bark.py index c52c541b25..fbf106272e 100644 --- a/TTS/tts/models/bark.py +++ b/TTS/tts/models/bark.py @@ -1,5 +1,6 @@ import os from dataclasses import dataclass +from pathlib import Path from typing import Optional import numpy as np @@ -269,10 +270,12 @@ def load_checkpoint( fine_model_path = fine_model_path or os.path.join(checkpoint_dir, "fine_2.pt") hubert_tokenizer_path = hubert_tokenizer_path or os.path.join(checkpoint_dir, "tokenizer.pth") + # The paths in the default config start with /root/.local/share/tts and need to be fixed self.config.LOCAL_MODEL_PATHS["text"] = text_model_path self.config.LOCAL_MODEL_PATHS["coarse"] = coarse_model_path self.config.LOCAL_MODEL_PATHS["fine"] = fine_model_path self.config.LOCAL_MODEL_PATHS["hubert_tokenizer"] = hubert_tokenizer_path + self.config.CACHE_DIR = str(Path(text_model_path).parent) self.load_bark_models()