Skip to content

Commit

Permalink
Update infer.py
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNeodev authored Dec 18, 2024
1 parent aed727e commit 95f82a8
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions rvc_inferpy/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
adjust_audio_lengths,
combine_silence_nonsilent,
)
import torch
from pathlib import Path
import requests
import os
Expand Down Expand Up @@ -84,28 +85,20 @@ 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()]


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!")


Expand All @@ -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:
Expand Down

0 comments on commit 95f82a8

Please sign in to comment.