"""Re-download RVC source with allow_patterns to skip junk and avoid 429.""" import os from huggingface_hub import snapshot_download LOCAL = "/home/runner/projects/rvc_npu/src/RVC" # What we need for NPU conversion: # - infer/ (infer-web, pipeline, modules/vc/, modules/transforms/) # - modules/ (vdecoder/hifigan NSF) # - infer_pack/ (models.py - has SynthesizerTrnMs768NSFsid) # - train/ (only data_utils for some imports) # - configs/ (v2/48k.json etc.) # - my_utils.py, config.py, export_onnx.py # - assets/, i18n/ # Skip: TEMP/, logs/, runtime/, docs/, __pycache__/, *.pt, *.pth, *.wav, *.npz patterns = [ "infer/**", "modules/**", "infer_pack/**", "train/**", "configs/**", "assets/**", "i18n/**", "i18n.py", "my_utils.py", "config.py", "export_onnx.py", "extract_f0_print.py", "extract_feature_print.py", "easy-infer.py", "infer-web.py", "infer-web-multi.py", "README.md", "requirements.txt", # also top-level *.py (filter for code) "*.py", ] # Remove junk dirs first import shutil for d in ["TEMP", "logs", "runtime", "__pycache__"]: p = os.path.join(LOCAL, d) if os.path.exists(p): print(f"removing junk: {p}") shutil.rmtree(p, ignore_errors=True) print("downloading with allow_patterns ...") snapshot_download( "audo/Retrieval-based-Voice-Conversion-WebUI", repo_type="model", local_dir=LOCAL, allow_patterns=patterns, max_workers=2, token=os.environ.get("HF_TOKEN"), ) print("done") # Sanity check for needed in [ "infer/modules/vc/vc_inference.py", "infer/modules/vc/pipeline.py", "infer/modules/transforms/extractor.py", "infer_pack/models.py", "infer_pack/commons.py", "infer_pack/attentions.py", "infer_pack/modules.py", "infer_pack/transforms.py", "modules/vdecoder/hifigan/nv_hifigan.py", "configs/v2/48k.json", "my_utils.py", "config.py", "export_onnx.py", ]: p = os.path.join(LOCAL, needed) sz = os.path.getsize(p) if os.path.exists(p) else "MISSING" print(f" {needed}: {sz}")