22 lines
887 B
Python
22 lines
887 B
Python
import os.path
|
|
import shutil
|
|
|
|
import huggingface_hub
|
|
|
|
import folder_paths
|
|
|
|
|
|
class HuBERTManager:
|
|
@staticmethod
|
|
def make_sure_tokenizer_installed(model: str = 'quantifier_hubert_base_ls960_14.pth', repo: str = 'GitMylo/bark-voice-cloning', local_file: str = 'tokenizer.pth'):
|
|
install_dir = os.path.join(folder_paths.models_dir, "bark", "quantizers", local_file)
|
|
if not os.path.isdir(install_dir):
|
|
os.makedirs(install_dir, exist_ok=True)
|
|
install_file = os.path.join(install_dir, local_file)
|
|
if not os.path.isfile(install_file):
|
|
print('Downloading HuBERT custom tokenizer')
|
|
huggingface_hub.hf_hub_download(repo, model, local_dir=install_dir, local_dir_use_symlinks=False)
|
|
shutil.move(os.path.join(install_dir, model), install_file)
|
|
print('Downloaded tokenizer')
|
|
return install_file
|