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

[Feature]: Improve File Path Handling #959

Open
justivanr opened this issue Jan 22, 2025 · 1 comment
Open

[Feature]: Improve File Path Handling #959

justivanr opened this issue Jan 22, 2025 · 1 comment
Labels
enhancement New feature or request feature

Comments

@justivanr
Copy link

Description

Current path handling assumes that code will always be executed from the library's directory, making it difficult to use the the library's functionalities outside of it.

Problem

Tried calling some methods from the core.py script in another script (outside the library's directory), but got errors concerning folders or files not being found.

Proposed Solution

For instance, I have temporarly solved this by replacing the way you handle the now_dir in certain files as follows:

Old Code:

now_dir = os.getcwd()
sys.path.append(now_dir)

My Solution:

now_dir = os.path.realpath(__file__)
applio_dir_len = now_dir .find("Applio") + len("Applio")
now_dir = now_dir [:applio_dir_len]
sys.path.append(os.path.join(now_dir))

In other scripts, I had to add the current_directory to os.path.join for certain files. For instance, in the preparing_files.py script, I had to do this:

current_directory = os.path.realpath(__file__)
applio_dir_len = current_directory .find("Applio") + len("Applio")
current_directory= current_directory[:applio_dir_len]

def generate_config(rvc_version: str, sample_rate: int, model_path: str):
    # Added 'current_directory' to os.path.join
    config_path = os.path.join(current_directory, "rvc", "configs", rvc_version, f"{sample_rate}.json")
    config_save_path = os.path.join(model_path, "config.json")
    if not os.path.exists(config_save_path):
        shutil.copyfile(config_path, config_save_path)

Alternatives Considered

idk

@justivanr justivanr added enhancement New feature or request feature labels Jan 22, 2025
@blaisewf
Copy link
Member

code is made to work in applio, that’s our focus

feel free to open a pr with your improvement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature
Projects
None yet
Development

No branches or pull requests

2 participants