Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileNotFoundError: [Errno 2] No such file or directory: 'rvc/lib/uvr5_pack/lib_v5/modelparams/4band_v2.json' when using UVR.uvr_wrapper() #7

Open
wAIfu-DEV opened this issue Jan 27, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@wAIfu-DEV
Copy link

wAIfu-DEV commented Jan 27, 2024

Hi, getting this error when using the UVR.uvr_wrapper() function:

Loading UVR
Extracting vocals...
Traceback (most recent call last):
  File "C:\Users\jeje9\Desktop\rvc_test\rvc_test.py", line 27, in <module>
    for i in result:
  File "C:\Users\jeje9\Desktop\rvc_test\lib\site-packages\rvc\modules\uvr5\modules.py", line 49, in uvr_wrapper
    pre_fun = func(
  File "C:\Users\jeje9\Desktop\rvc_test\lib\site-packages\rvc\modules\uvr5\vr.py", line 31, in __init__
    mp = ModelParameters("rvc/lib/uvr5_pack/lib_v5/modelparams/4band_v2.json")
  File "C:\Users\jeje9\Desktop\rvc_test\lib\site-packages\rvc\lib\uvr5_pack\lib_v5\model_param_init.py", line 55, in __init__
    with open(config_path, "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'rvc/lib/uvr5_pack/lib_v5/modelparams/4band_v2.json'

Here is my code:

import os

from dotenv import load_dotenv
from rvc.modules.uvr5.modules import UVR

# downloaded uvr model from:
# https://github.com/TRvlvr/model_repo/releases/

cwd = os.getcwd()
load_dotenv(".env")

print("Loading UVR")
uvr = UVR()

print("Extracting vocals...")

result = uvr.uvr_wrapper(
    model_name="2_HP-UVR.pth",
    audio_path=cwd + "audio.wav",
    save_vocal_path=cwd + "vocal.wav",
    save_ins_path=cwd + "inst.wav",
    agg=10, 
    export_format="wav",
    temp_path=cwd + "tmp.wav")

for i in result:
    print(i)

I made sure to look at the path, and the file does exist, so I'm thinking it might be an issue with the expected CWD since the path is relative.
For more info: I'm running python from a venv and using this command to run: ./Scripts/python.exe rvc_test.py from the C:\Users\jeje9\Desktop\rvc_test directory where the rvc_test.py file is

@wAIfu-DEV
Copy link
Author

wAIfu-DEV commented Jan 27, 2024

This indeed seems to be the cause of the crash. I took the liberty to add a print statement in the source code, right before the call to open()
image
And got the path: C:\Users\jeje9\Desktop\rvc_test\rvc\lib\uvr5_pack\lib_v5\modelparams\4band_v2.json when the correct path should have been: C:\Users\jeje9\Desktop\rvc_test\lib\site-packages\rvc\lib\uvr5_pack\lib_v5\modelparams\4band_v2.json

@wAIfu-DEV
Copy link
Author

wAIfu-DEV commented Jan 27, 2024

Manually setting the CWD of the python script using os.chdir() fixes the issue on my end.

import os
import pydub

cwd = os.getcwd()
ffmpeg_exec = cwd + "\\ffmpeg.exe" # or any other path to ffmpeg, as long as it is absolute and not relative.

pydub.AudioSegment.converter = ffmpeg_exec

from dotenv import load_dotenv
from rvc.modules.uvr5.modules import UVR

# downloaded model from:
# https://github.com/TRvlvr/model_repo/releases/

load_dotenv(".env")

print(cwd)

print("Loading UVR")
uvr = UVR()

print("Extracting vocals...")

os.chdir(cwd + "\\Lib\\site-packages")

result = uvr.uvr_wrapper(
    model_name="2_HP-UVR.pth",
    audio_path=cwd + "\\audio.wav",
    save_vocal_path=cwd + "\\vocal",
    save_ins_path=cwd + "\\inst",
    agg=5,
    export_format="wav",
    temp_path=cwd + "\\tmp")

for i in result:
    print(i)

@Tps-F
Copy link
Member

Tps-F commented Feb 4, 2024

Sorry it took me so long to notice.
I haven't tested it on windows yet, I'll fix it again.

@Tps-F Tps-F added the bug Something isn't working label Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants