Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bark): handle broken paths in config #253

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading