rvc-models / scripts /setup /download_pretrained.py
mistmlm's picture
rvc-model: build scripts, manifests and voice notes (mygf_wh now v73)
bda6de8 verified
Raw History Blame Contribute Delete
1.84 kB
import os
os.environ["HF_HUB_DISABLE_XET"] = "1"
from huggingface_hub import hf_hub_download
from concurrent.futures import ThreadPoolExecutor
import sys
# Use absolute paths so venv's cwd doesn't matter
BASE = os.path.expanduser("~/projects/rvc_npu/models")
os.makedirs(f"{BASE}/hubert", exist_ok=True)
os.makedirs(f"{BASE}/rmvpe", exist_ok=True)
os.makedirs(f"{BASE}/synthesizer", exist_ok=True)
DL = []
# HuBERT (360MB)
DL.append(("ddPn08/rvc_pretrained", "hubert_base.pt", f"{BASE}/hubert/hubert_base.pt"))
# RMVPE - both formats
DL.append(("choongholee/rmvpe_model", "rmvpe.pt", f"{BASE}/rmvpe/rmvpe_choongholee.pt"))
DL.append(("safe-models/RMVPE", "model.safetensors", f"{BASE}/rmvpe/rmvpe_safemodels.safetensors"))
# Synthesizer v2 40k (most common pitch + sampling rate config)
DL.append(("ddPn08/rvc_pretrained", "G40k.pth", f"{BASE}/synthesizer/G40k.pth"))
DL.append(("ddPn08/rvc_pretrained", "D40k.pth", f"{BASE}/synthesizer/D40k.pth")) # not used in inference, but referenced
DL.append(("ddPn08/rvc_pretrained", "f0G40k.pth", f"{BASE}/synthesizer/f0G40k.pth"))
def do_one(item):
repo, fname, dst = item
if os.path.exists(dst) and os.path.getsize(dst) > 1000:
print(f" [SKIP] {dst} ({os.path.getsize(dst)} bytes)", flush=True)
return dst
print(f" [GO] {repo}/{fname} -> {dst}", flush=True)
p = hf_hub_download(repo_id=repo, filename=fname, local_dir=os.path.dirname(dst))
# hf_hub_download uses local_dir/repo_id/filename structure, move if needed
src = os.path.join(os.path.dirname(dst), repo, fname)
if os.path.exists(src) and src != dst:
os.rename(src, dst)
sz = os.path.getsize(dst)
print(f" [OK] {dst} = {sz/1024/1024:.1f} MB", flush=True)
return dst
with ThreadPoolExecutor(max_workers=4) as ex:
list(ex.map(do_one, DL))
print("ALL DONE")