diff --git a/server/MMVCServerSIO.py b/server/MMVCServerSIO.py index d11d8143..70c266ad 100755 --- a/server/MMVCServerSIO.py +++ b/server/MMVCServerSIO.py @@ -131,6 +131,28 @@ def download(params): print(e) +def download_no_tqdm(params): + url = params["url"] + saveTo = params["saveTo"] + dirname = os.path.dirname(saveTo) + if dirname != "": + os.makedirs(dirname, exist_ok=True) + try: + req = requests.get(url, stream=True, allow_redirects=True) + with open(saveTo, "wb") as f: + countToDot = 0 + for chunk in req.iter_content(chunk_size=1024): + if chunk: + f.write(chunk) + countToDot += 1 + if countToDot % 1024 == 0: + print(".", end="") + + print("+", end="") + except Exception as e: + print(e) + + def downloadWeight(): # content_vec_500 = (args.content_vec_500,) # content_vec_500_onnx = (args.content_vec_500_onnx,) @@ -232,7 +254,7 @@ if __name__ == "MMVCServerSIO": ) try: - download({"url": SAMPLES_JSON, "saveTo": args.samples, "position": 0}) + download_no_tqdm({"url": SAMPLES_JSON, "saveTo": args.samples, "position": 0}) except Exception as e: print("[Voice Changer] loading sample failed", e) diff --git a/server/voice_changer/RVC/RVC.py b/server/voice_changer/RVC/RVC.py index 70bf0c2b..684d70cf 100644 --- a/server/voice_changer/RVC/RVC.py +++ b/server/voice_changer/RVC/RVC.py @@ -6,7 +6,7 @@ from dataclasses import asdict from typing import cast import numpy as np import torch -from MMVCServerSIO import download +from MMVCServerSIO import download_no_tqdm from ModelSample import RVCModelSample, getModelSamples @@ -130,8 +130,11 @@ class RVC: "position": 2, } ) + + print("[Voice Changer] Downloading model files...", end="") with ThreadPoolExecutor() as pool: - pool.map(download, downloadParams) + pool.map(download_no_tqdm, downloadParams) + print("") return modelPath, indexPath, featurePath def loadModel(self, props: LoadModelParams):