File size: 1,098 Bytes
c8be32d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
This script downloads the models required for running the Ultimmate RVC app.
"""

import os

import requests

from common import RVC_MODELS_DIR

RVC_DOWNLOAD_LINK = "https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/"


def dl_model(link: str, model_name: str, dir_name: str) -> None:
    """
    Download a model from a link and save it to a directory.

    Parameters
    ----------
    link : str
        The link to the site where the model is hosted.
    model_name : str
        The name of the model to download.
    dir_name : str
        The directory to save the model to.
    """
    with requests.get(f"{link}{model_name}") as r:
        r.raise_for_status()
        with open(os.path.join(dir_name, model_name), "wb") as f:
            for chunk in r.iter_content(chunk_size=8192):
                f.write(chunk)


if __name__ == "__main__":

    rvc_model_names = ["hubert_base.pt", "rmvpe.pt"]
    for model in rvc_model_names:
        print(f"Downloading {model}...")
        dl_model(RVC_DOWNLOAD_LINK, model, RVC_MODELS_DIR)

    print("All models downloaded!")