From fb2960e3363a893efddea1b18e3db8c88958f27e Mon Sep 17 00:00:00 2001 From: Ftps Date: Sun, 21 Jan 2024 11:59:32 +0900 Subject: [PATCH] move cli --- rvc/cli/cli.py | 33 --------- rvc/cli/handler/infer.py | 130 ------------------------------------ rvc/cli/handler/train.py | 6 -- rvc/cli/handler/uvr5.py | 6 -- rvc/cli/utils/dlmodel.py | 9 --- rvc/cli/utils/env.py | 40 ----------- rvc/cli/utils/initialize.py | 11 --- 7 files changed, 235 deletions(-) delete mode 100644 rvc/cli/cli.py delete mode 100644 rvc/cli/handler/infer.py delete mode 100644 rvc/cli/handler/train.py delete mode 100644 rvc/cli/handler/uvr5.py delete mode 100644 rvc/cli/utils/dlmodel.py delete mode 100644 rvc/cli/utils/env.py delete mode 100644 rvc/cli/utils/initialize.py diff --git a/rvc/cli/cli.py b/rvc/cli/cli.py deleted file mode 100644 index 96815e4..0000000 --- a/rvc/cli/cli.py +++ /dev/null @@ -1,33 +0,0 @@ -import re -from typing import Optional, Pattern - -import click - -from rvc.cli.handler.infer import infer -from rvc.cli.handler.train import train -from rvc.cli.handler.uvr5 import uvr -from rvc.cli.utils.dlmodel import dlmodel -from rvc.cli.utils.env import env -from rvc.cli.utils.initialize import init - - -@click.group( - context_settings={"help_option_names": ["-h", "--help"]}, - help="rvc cli feature list", -) -def cli(): - pass - - -def main(): - cli.add_command(infer) - cli.add_command(train) - cli.add_command(uvr) - cli.add_command(dlmodel) - cli.add_command(env) - cli.add_command(init) - cli() - - -if __name__ == "__main__": - main() diff --git a/rvc/cli/handler/infer.py b/rvc/cli/handler/infer.py deleted file mode 100644 index beb7f3b..0000000 --- a/rvc/cli/handler/infer.py +++ /dev/null @@ -1,130 +0,0 @@ -import logging -from pathlib import Path - -import click -from dotenv import load_dotenv -from scipy.io import wavfile - -from rvc.modules.vc.modules import VC - -logging.getLogger("numba").setLevel(logging.WARNING) - - -@click.command( - context_settings={"help_option_names": ["-h", "--help"]}, - help="inference audio", -) -@click.option( - "-m", - "--modelPath", - is_flag=False, - type=str, - help="Model path or filename (reads in the directory set in env)", - required=True, -) -@click.option( - "-i", - "--inputPath", - is_flag=False, - type=Path, - help="input audio path or folder", - required=True, -) -@click.option( - "-o", - "--outputPath", - is_flag=False, - type=Path, - help="output audio path or folder", - required=True, -) -@click.option( - "-s", "--sid", is_flag=False, type=int, help="Speaker/Singer id", default=0 -) -@click.option("-fu", "--f0upkey", is_flag=False, type=int, help="Transpose", default=0) -@click.option( - "-fm", - "--f0method", - is_flag=False, - type=str, - help="Pitch extraction algorith", - default="rmvpe", -) -@click.option( - "-ff", "--f0file", is_flag=False, type=Path, help="F0 curve file (optional)" -) -@click.option("-if", "--indexFile", is_flag=False, type=Path, help="Feature index file") -@click.option( - "-ir", - "--indexRate", - is_flag=False, - type=float, - help="Search feature ratio", - default=0.75, -) -@click.option( - "-fr", - "--filterRadius", - is_flag=False, - type=int, - help="Apply median filtering", - default=3, -) -@click.option( - "-rsr", - "--resamplesr", - is_flag=False, - type=int, - help="Resample the output audio", - default=0, -) -@click.option( - "-rmr", - "--rmsmixrate", - is_flag=False, - type=float, - help="Adjust the volume envelope scaling", - default=0.25, -) -@click.option( - "-p", - "--protect", - is_flag=False, - type=float, - help="Protect voiceless consonants and breath sounds", - default=0.33, -) -def infer( - modelpath, - inputpath, - outputpath, - sid, - f0upkey, - f0method, - f0file, - indexfile, - indexrate, - filterradius, - resamplesr, - rmsmixrate, - protect, -): - load_dotenv() - vc = VC() - vc.get_vc(modelpath) - tgt_sr, audio_opt, times, _ = vc.vc_single( - sid, - inputpath, - f0upkey, - f0method, - f0file, - indexfile, - indexrate, - filterradius, - resamplesr, - rmsmixrate, - protect, - ) - wavfile.write(outputpath, tgt_sr, audio_opt) - click.echo(times) - click.echo(f"Finish inference. Check {outputpath}") diff --git a/rvc/cli/handler/train.py b/rvc/cli/handler/train.py deleted file mode 100644 index d5ff831..0000000 --- a/rvc/cli/handler/train.py +++ /dev/null @@ -1,6 +0,0 @@ -import click - - -@click.command() -def train(): - pass diff --git a/rvc/cli/handler/uvr5.py b/rvc/cli/handler/uvr5.py deleted file mode 100644 index 249ec6b..0000000 --- a/rvc/cli/handler/uvr5.py +++ /dev/null @@ -1,6 +0,0 @@ -import click - - -@click.command() -def uvr(): - pass diff --git a/rvc/cli/utils/dlmodel.py b/rvc/cli/utils/dlmodel.py deleted file mode 100644 index 6322648..0000000 --- a/rvc/cli/utils/dlmodel.py +++ /dev/null @@ -1,9 +0,0 @@ -import urllib - -import click - - -@click.command() -def dlmodel() -> None: - # Download models [harvest, uvr5, and more ] - pass diff --git a/rvc/cli/utils/env.py b/rvc/cli/utils/env.py deleted file mode 100644 index 0393dd4..0000000 --- a/rvc/cli/utils/env.py +++ /dev/null @@ -1,40 +0,0 @@ -""" -setup or cleanup enviroment file -usage: rvc env [create / cleanup] -Default: [nowDir/.env] - -""" - -import os - -import click - - -@click.group() -def env(): - pass - - -@env.command() -def create(): - env_file_path = os.path.join(os.getcwd(), ".env") - - if not os.path.exists(env_file_path): - default_values = { - "weight_root": "", - "weight_uvr5_root": "", - "index_root": "", - "rmvpe_root": "", - "hubert_path": "", - "save_uvr_path": "", - "TEMP": "", - "pretrained": "", - } - - with open(env_file_path, "w") as env_file: - for key, value in default_values.items(): - env_file.write(f"{key}={value}\n") - - click.echo(f"{env_file_path} created successfully.") - else: - click.echo(f"{env_file_path} already exists, no change") diff --git a/rvc/cli/utils/initialize.py b/rvc/cli/utils/initialize.py deleted file mode 100644 index eda931c..0000000 --- a/rvc/cli/utils/initialize.py +++ /dev/null @@ -1,11 +0,0 @@ -""" -Uage: rvc init -download model and setup environmmnt file - -""" -import click - - -@click.command() -def init(): - pass