feat(rvcmd): add dns and dl link fallback

This commit is contained in:
源文雨 2024-04-21 01:59:01 +09:00
parent 652f33ed1c
commit 229fe68818
9 changed files with 57 additions and 28 deletions

View File

@ -19,7 +19,7 @@ jobs:
run: |
sudo apt update
sudo apt -y install ffmpeg
wget https://github.com/RVC-Project/RVC-Models-Downloader/releases/download/v0.2.1/rvcmd_linux_amd64.deb
wget https://github.com/RVC-Project/RVC-Models-Downloader/releases/download/v0.2.2/rvcmd_linux_amd64.deb
sudo apt -y install ./rvcmd_linux_amd64.deb
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools

View File

@ -1,2 +1,2 @@
runtime\python.exe gui_v1.py --pycmd runtime\python.exe --dml
runtime\python.exe gui_v1.py --pycmd runtime\python.exe --nocheck --dml
pause

View File

@ -1,2 +1,2 @@
runtime\python.exe gui_v1.py
runtime\python.exe --nocheck gui_v1.py
pause

View File

@ -1,2 +1,2 @@
runtime\python.exe infer-web.py --pycmd runtime\python.exe --port 7897 --dml
runtime\python.exe infer-web.py --pycmd runtime\python.exe --nocheck --port 7897 --dml
pause

View File

@ -1,2 +1,2 @@
runtime\python.exe infer-web.py --pycmd runtime\python.exe --port 7897
runtime\python.exe infer-web.py --pycmd runtime\python.exe --nocheck --port 7897
pause

View File

@ -13,7 +13,6 @@ from infer.lib.train.process_ckpt import (
merge,
show_info,
)
from infer.lib.rvcmd import check_all_assets, download_all_assets
from i18n.i18n import I18nAuto
from configs.config import Config
from sklearn.cluster import MiniBatchKMeans
@ -54,11 +53,13 @@ torch.manual_seed(114514)
config = Config()
vc = VC(config)
if not config.nocheck and not check_all_assets():
download_all_assets(tmpdir=tmp)
if not config.nocheck:
from infer.lib.rvcmd import check_all_assets, download_all_assets
if not check_all_assets():
logging.error("counld not satisfy all assets needed.")
exit(1)
download_all_assets(tmpdir=tmp)
if not check_all_assets():
logging.error("counld not satisfy all assets needed.")
exit(1)
if config.dml == True:

View File

@ -30,6 +30,7 @@ def check_model(dir_name: Path, model_name: str, hash: str) -> bool:
logger.info(f"{target} sha256 hash mismatch.")
logger.info(f"expected: {hash}")
logger.info(f"real val: {digest}")
os.remove(str(target))
return False
return True
@ -113,7 +114,7 @@ def download_and_extract_tar_gz(url: str, folder: str):
import tarfile
logger.info(f"downloading {url}")
response = requests.get(url, stream=True)
response = requests.get(url, stream=True, timeout=(5,10))
with BytesIO() as out_file:
out_file.write(response.content)
out_file.seek(0)
@ -127,7 +128,7 @@ def download_and_extract_zip(url: str, folder: str):
import zipfile
logger.info(f"downloading {url}")
response = requests.get(url)
response = requests.get(url, stream=True, timeout=(5,10))
with BytesIO() as out_file:
out_file.write(response.content)
out_file.seek(0)
@ -136,8 +137,14 @@ def download_and_extract_zip(url: str, folder: str):
zip_ref.extractall(folder)
logger.info(f"extracted into {folder}")
def download_dns_yaml(url: str, folder: str):
logger.info(f"downloading {url}")
response = requests.get(url, stream=True, timeout=(5,10))
with open(f"{folder}/dns.yaml", "wb") as out_file:
out_file.write(response.content)
logger.info(f"downloaded into {folder}")
def download_all_assets(tmpdir: str, version="0.2.1"):
def download_all_assets(tmpdir: str, version="0.2.2"):
import subprocess
import platform
@ -161,14 +168,35 @@ def download_all_assets(tmpdir: str, version="0.2.1"):
if not architecture:
logger.error(f"architecture {architecture} is not supported")
exit(1)
BASE_URL = "https://github.com/RVC-Project/RVC-Models-Downloader/releases/download/"
suffix = "zip" if is_win else "tar.gz"
RVCMD_URL = BASE_URL + f"v{version}/rvcmd_{system_type}_{architecture}.{suffix}"
cmdfile = tmpdir + "/rvcmd"
if is_win:
download_and_extract_zip(RVCMD_URL, tmpdir)
cmdfile += ".exe"
else:
download_and_extract_tar_gz(RVCMD_URL, tmpdir)
os.chmod(cmdfile, 0o755)
subprocess.run([cmdfile, "-notui", "-w", "0", "assets/all"])
try:
BASE_URL = "https://github.com/RVC-Project/RVC-Models-Downloader/releases/download/"
suffix = "zip" if is_win else "tar.gz"
RVCMD_URL = BASE_URL + f"v{version}/rvcmd_{system_type}_{architecture}.{suffix}"
cmdfile = tmpdir + "/rvcmd"
if is_win:
download_and_extract_zip(RVCMD_URL, tmpdir)
cmdfile += ".exe"
else:
download_and_extract_tar_gz(RVCMD_URL, tmpdir)
os.chmod(cmdfile, 0o755)
subprocess.run([cmdfile, "-notui", "-w", "0", "assets/all"])
except Exception:
BASE_URL = "https://raw.gitcode.com/u011570312/RVC-Models-Downloader/assets/"
suffix = {
"darwin_amd64": "421",
"darwin_arm64": "422",
"linux_386": "423",
"linux_amd64": "424",
"linux_arm64": "425",
"windows_386": "426",
"windows_amd64": "427",
}[f"{system_type}_{architecture}"]
RVCMD_URL = BASE_URL + suffix
download_dns_yaml("https://raw.gitcode.com/u011570312/RVC-Models-Downloader/raw/main/dns.yaml", tmpdir)
if is_win:
download_and_extract_zip(RVCMD_URL, tmpdir)
cmdfile += ".exe"
else:
download_and_extract_tar_gz(RVCMD_URL, tmpdir)
os.chmod(cmdfile, 0o755)
subprocess.run([cmdfile, "-notui", "-w", "0", "-dns", f"{tmpdir}/dns.yaml", "assets/all"])

View File

@ -94,7 +94,7 @@
"outputs": [],
"source": [
"# @title 下载安装 RVC-Models-Downloader\n",
"!wget https://github.com/RVC-Project/RVC-Models-Downloader/releases/download/v0.2.1/rvcmd_linux_amd64.deb\n",
"!wget https://github.com/RVC-Project/RVC-Models-Downloader/releases/download/v0.2.2/rvcmd_linux_amd64.deb\n",
"!apt install ./rvcmd_linux_amd64.deb"
]
},
@ -350,4 +350,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}

View File

@ -94,7 +94,7 @@
"outputs": [],
"source": [
"# @title 下载安装 RVC-Models-Downloader\n",
"!wget https://github.com/RVC-Project/RVC-Models-Downloader/releases/download/v0.2.1/rvcmd_linux_amd64.deb\n",
"!wget https://github.com/RVC-Project/RVC-Models-Downloader/releases/download/v0.2.2/rvcmd_linux_amd64.deb\n",
"!apt install ./rvcmd_linux_amd64.deb"
]
},
@ -349,4 +349,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}