Skip to content

Commit

Permalink
chore(bark): remove manual download of hubert model
Browse files Browse the repository at this point in the history
Bark was previously adapted to download Hubert from HuggingFace, so the manual
download is superfluous.
  • Loading branch information
eginhard committed Sep 12, 2024
1 parent 126c781 commit c8396d9
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 8 deletions.
1 change: 0 additions & 1 deletion TTS/.models.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"https://coqui.gateway.scarf.sh/hf/bark/fine_2.pt",
"https://coqui.gateway.scarf.sh/hf/bark/text_2.pt",
"https://coqui.gateway.scarf.sh/hf/bark/config.json",
"https://coqui.gateway.scarf.sh/hf/bark/hubert.pt",
"https://coqui.gateway.scarf.sh/hf/bark/tokenizer.pth"
],
"default_vocoder": null,
Expand Down
1 change: 0 additions & 1 deletion TTS/tts/configs/bark_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def __post_init__(self):
"coarse": os.path.join(self.CACHE_DIR, "coarse_2.pt"),
"fine": os.path.join(self.CACHE_DIR, "fine_2.pt"),
"hubert_tokenizer": os.path.join(self.CACHE_DIR, "tokenizer.pth"),
"hubert": os.path.join(self.CACHE_DIR, "hubert.pt"),
}
self.SMALL_REMOTE_MODEL_PATHS = {
"text": {"path": os.path.join(self.REMOTE_BASE_URL, "text.pt")},
Expand Down
2 changes: 1 addition & 1 deletion TTS/tts/layers/bark/hubert/kmeans_hubert.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CustomHubert(nn.Module):
or you can train your own
"""

def __init__(self, checkpoint_path, target_sample_hz=16000, seq_len_multiple_of=None, output_layer=9, device=None):
def __init__(self, target_sample_hz=16000, seq_len_multiple_of=None, output_layer=9, device=None):
super().__init__()
self.target_sample_hz = target_sample_hz
self.seq_len_multiple_of = seq_len_multiple_of
Expand Down
3 changes: 1 addition & 2 deletions TTS/tts/layers/bark/inference_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,9 @@ def generate_voice(
# generate semantic tokens
# Load the HuBERT model
hubert_manager = HubertManager()
# hubert_manager.make_sure_hubert_installed(model_path=model.config.LOCAL_MODEL_PATHS["hubert"])
hubert_manager.make_sure_tokenizer_installed(model_path=model.config.LOCAL_MODEL_PATHS["hubert_tokenizer"])

hubert_model = CustomHubert(checkpoint_path=model.config.LOCAL_MODEL_PATHS["hubert"]).to(model.device)
hubert_model = CustomHubert().to(model.device)

# Load the CustomTokenizer model
tokenizer = HubertTokenizer.load_from_checkpoint(
Expand Down
3 changes: 0 additions & 3 deletions TTS/tts/models/bark.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ def load_checkpoint(
text_model_path=None,
coarse_model_path=None,
fine_model_path=None,
hubert_model_path=None,
hubert_tokenizer_path=None,
eval=False,
strict=True,
Expand All @@ -266,13 +265,11 @@ def load_checkpoint(
text_model_path = text_model_path or os.path.join(checkpoint_dir, "text_2.pt")
coarse_model_path = coarse_model_path or os.path.join(checkpoint_dir, "coarse_2.pt")
fine_model_path = fine_model_path or os.path.join(checkpoint_dir, "fine_2.pt")
hubert_model_path = hubert_model_path or os.path.join(checkpoint_dir, "hubert.pt")
hubert_tokenizer_path = hubert_tokenizer_path or os.path.join(checkpoint_dir, "tokenizer.pth")

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"] = hubert_model_path
self.config.LOCAL_MODEL_PATHS["hubert_tokenizer"] = hubert_tokenizer_path

self.load_bark_models()
Expand Down

0 comments on commit c8396d9

Please sign in to comment.