File size: 2,125 Bytes
bda6de8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""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}")