Skip to content

Commit

Permalink
fix(bark): handle broken paths in config (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
eginhard authored Jan 10, 2025
1 parent e17723a commit 88485d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion TTS/tts/layers/bark/load_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions TTS/tts/models/bark.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from dataclasses import dataclass
from pathlib import Path
from typing import Optional

import numpy as np
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 88485d9

Please sign in to comment.