mirror of
https://github.com/serp-ai/bark-with-voice-clone.git
synced 2026-04-03 09:46:24 +02:00
Add better voice clones and prepare for finetuning
This commit is contained in:
35
hubert/hubert_manager.py
Normal file
35
hubert/hubert_manager.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# From https://github.com/gitmylo/bark-voice-cloning-HuBERT-quantizer
|
||||
|
||||
import os.path
|
||||
import shutil
|
||||
import urllib.request
|
||||
|
||||
import huggingface_hub
|
||||
|
||||
|
||||
class HuBERTManager:
|
||||
@staticmethod
|
||||
def make_sure_hubert_installed(download_url: str = 'https://dl.fbaipublicfiles.com/hubert/hubert_base_ls960.pt', file_name: str = 'hubert.pt'):
|
||||
install_dir = os.path.join('data', 'models', 'hubert')
|
||||
if not os.path.isdir(install_dir):
|
||||
os.makedirs(install_dir, exist_ok=True)
|
||||
install_file = os.path.join(install_dir, file_name)
|
||||
if not os.path.isfile(install_file):
|
||||
print('Downloading HuBERT base model')
|
||||
urllib.request.urlretrieve(download_url, install_file)
|
||||
print('Downloaded HuBERT')
|
||||
return install_file
|
||||
|
||||
|
||||
@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('data', 'models', 'hubert')
|
||||
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
|
||||
Reference in New Issue
Block a user