move cli and api into wrapper
This commit is contained in:
@@ -34,10 +34,10 @@ numba = "0.59.0rc1"
|
||||
api = ["uvicorn", "fastapi"]
|
||||
|
||||
[tool.poetry.scripts]
|
||||
rvc = "rvc.utils.cli.cli:main"
|
||||
rvc = "rvc.wrapper.cli.cli:main"
|
||||
|
||||
[tool.poe.tasks]
|
||||
rvc-api = "uvicorn rvc.utils.api.api:app --reload"
|
||||
rvc-api = "uvicorn rvc.wrapper.api.api:app --reload"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import click
|
||||
|
||||
|
||||
@click.command()
|
||||
def uvr():
|
||||
pass
|
||||
@@ -1,8 +1,8 @@
|
||||
import uvicorn
|
||||
from dotenv import load_dotenv
|
||||
from fastapi import FastAPI
|
||||
import uvicorn
|
||||
|
||||
from rvc.utils.api.endpoints import inference
|
||||
from rvc.wrapper.api.endpoints import inference
|
||||
|
||||
load_dotenv()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import APIRouter, UploadFile, Response, responses
|
||||
from fastapi import APIRouter, Response, UploadFile, responses
|
||||
from pydantic import BaseModel
|
||||
from scipy.io import wavfile
|
||||
|
||||
18
rvc/wrapper/api/endpoints/uvr.py
Normal file
18
rvc/wrapper/api/endpoints/uvr.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from fastapi import APIRouter, Response, UploadFile, responses
|
||||
|
||||
from rvc.modules.uvr5.modules import UVR
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/inference")
|
||||
def uvr(inputpath, outputpath, modelname, format):
|
||||
uvr_module = UVR()
|
||||
uvr_module.uvr_wrapper(
|
||||
inputpath, outputpath, model_name=modelname, export_format=format
|
||||
)
|
||||
return responses.StreamingResponse(
|
||||
audio,
|
||||
media_type="audio/wav",
|
||||
headers={"Content-Disposition": "attachment; filename=inference.wav"},
|
||||
)
|
||||
@@ -3,12 +3,12 @@ from typing import Optional, Pattern
|
||||
|
||||
import click
|
||||
|
||||
from rvc.utils.cli.handler.infer import infer
|
||||
from rvc.utils.cli.handler.train import train
|
||||
from rvc.utils.cli.handler.uvr5 import uvr
|
||||
from rvc.utils.cli.utils.dlmodel import dlmodel
|
||||
from rvc.utils.cli.utils.env import env
|
||||
from rvc.utils.cli.utils.initialize import init
|
||||
from rvc.wrapper.cli.handler.infer import infer
|
||||
from rvc.wrapper.cli.handler.train import train
|
||||
from rvc.wrapper.cli.handler.uvr5 import uvr
|
||||
from rvc.wrapper.cli.utils.dlmodel import dlmodel
|
||||
from rvc.wrapper.cli.utils.env import env
|
||||
from rvc.wrapper.cli.utils.initialize import init
|
||||
|
||||
|
||||
@click.group(
|
||||
@@ -5,8 +5,6 @@ import click
|
||||
from dotenv import load_dotenv
|
||||
from scipy.io import wavfile
|
||||
|
||||
|
||||
|
||||
logging.getLogger("numba").setLevel(logging.WARNING)
|
||||
|
||||
|
||||
@@ -110,6 +108,7 @@ def infer(
|
||||
protect,
|
||||
):
|
||||
from rvc.modules.vc.modules import VC
|
||||
|
||||
load_dotenv()
|
||||
vc = VC()
|
||||
vc.get_vc(modelpath)
|
||||
45
rvc/wrapper/cli/handler/uvr5.py
Normal file
45
rvc/wrapper/cli/handler/uvr5.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from pathlib import Path
|
||||
|
||||
import click
|
||||
|
||||
from rvc.modules.uvr5.modules import UVR
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option(
|
||||
"-m",
|
||||
"--modelName",
|
||||
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(
|
||||
"-f",
|
||||
"--format",
|
||||
is_flag=False,
|
||||
type=str,
|
||||
help="output Format",
|
||||
)
|
||||
def uvr(modelname, inputpath, outputpath, format):
|
||||
uvr_module = UVR()
|
||||
uvr_module.uvr_wrapper(
|
||||
inputpath, outputpath, model_name=modelname, export_format=format
|
||||
)
|
||||
click.echo(f"Finish uvr5. Check {outputpath}")
|
||||
Reference in New Issue
Block a user