Merge pull request #57 from idiap/xtts-vocab

fix(xtts): load tokenizer file based on config as last resort
This commit is contained in:
Enno Hermann 2024-07-25 13:26:28 +01:00 committed by GitHub
commit 20583a496e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import logging import logging
import os import os
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path
import librosa import librosa
import torch import torch
@ -760,7 +761,11 @@ class Xtts(BaseTTS):
""" """
model_path = checkpoint_path or os.path.join(checkpoint_dir, "model.pth") model_path = checkpoint_path or os.path.join(checkpoint_dir, "model.pth")
vocab_path = vocab_path or os.path.join(checkpoint_dir, "vocab.json") if vocab_path is None:
if checkpoint_dir is not None and (Path(checkpoint_dir) / "vocab.json").is_file():
vocab_path = str(Path(checkpoint_dir) / "vocab.json")
else:
vocab_path = config.model_args.tokenizer_file
if speaker_file_path is None and checkpoint_dir is not None: if speaker_file_path is None and checkpoint_dir is not None:
speaker_file_path = os.path.join(checkpoint_dir, "speakers_xtts.pth") speaker_file_path = os.path.join(checkpoint_dir, "speakers_xtts.pth")