From 95f82a8902d184040fa4c681ad09b7c4557beb24 Mon Sep 17 00:00:00 2001 From: Neo Date: Wed, 18 Dec 2024 10:05:37 +0700 Subject: [PATCH] Update infer.py --- rvc_inferpy/infer.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/rvc_inferpy/infer.py b/rvc_inferpy/infer.py index 3578795..81359c2 100644 --- a/rvc_inferpy/infer.py +++ b/rvc_inferpy/infer.py @@ -9,6 +9,7 @@ adjust_audio_lengths, combine_silence_nonsilent, ) +import torch from pathlib import Path import requests import os @@ -84,9 +85,9 @@ def get_model(voice_model): ) -BASE_DIR = Path(os.getcwd()) -sys.path.append(str(BASE_DIR)) + +BASE_DIR = Path(".") files_to_check = ["hubert_base.pt", "rmvpe.pt", "fcpe.pt"] missing_files = [file for file in files_to_check if not (BASE_DIR / file).exists()] @@ -94,18 +95,10 @@ def get_model(voice_model): def dl_model(link, model_name, dir_name): url = f"{link}/{model_name}" - response = requests.get(url, stream=True) - response.raise_for_status() - target_path = dir_name / model_name - target_path.parent.mkdir( - parents=True, exist_ok=True - ) # Create the directory if it doesn't exist - - with open(target_path, "wb") as f: - for chunk in response.iter_content(chunk_size=8192): - f.write(chunk) + target_path.parent.mkdir(parents=True, exist_ok=True) # Ensure directory exists + torch.hub.download_url_to_file(url, str(target_path)) print(f"{model_name} downloaded successfully!") @@ -121,6 +114,7 @@ def dl_model(link, model_name, dir_name): pass + def extract_zip(extraction_folder, zip_name): os.makedirs(extraction_folder, exist_ok=True) with zipfile.ZipFile(zip_name, "r") as zip_ref: