Skip to content

Commit

Permalink
Revert "func -> call"
Browse files Browse the repository at this point in the history
This reverts commit 043fa4d.
  • Loading branch information
Tps-F committed Jun 1, 2024
1 parent 790b504 commit e02e007
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 50 deletions.
14 changes: 0 additions & 14 deletions .env

This file was deleted.

2 changes: 1 addition & 1 deletion rvc/modules/uvr5/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self):
self.need_reformat: bool = True
self.config: Config = Config()

def __call__(
def uvr_wrapper(
self,
audio_path: Path,
agg: int = 10,
Expand Down
6 changes: 1 addition & 5 deletions rvc/wrapper/api/endpoints/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from rvc.modules.vc.modules import VC
import glob
import os
import torch

router = APIRouter()
from dotenv import load_dotenv
Expand Down Expand Up @@ -44,6 +43,7 @@ def inference(
rms_mix_rate: float = 0.25,
protect: float = 0.33,
):
print(res_type)
vc = VC()
vc.get_vc(modelpath)
tgt_sr, audio_opt, times, _ = vc.vc_inference(
Expand All @@ -61,10 +61,6 @@ def inference(
)
wavfile.write(wv := BytesIO(), tgt_sr, audio_opt)
print(times)

if torch.cuda.is_available():
torch.cuda.empty_cache()

if res_type == "blob":
return responses.StreamingResponse(
wv,
Expand Down
36 changes: 11 additions & 25 deletions rvc/wrapper/api/endpoints/uvr.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
from io import BytesIO
from fastapi import APIRouter, Response, UploadFile, responses

from fastapi import APIRouter, UploadFile, responses, Query
from fastapi.responses import JSONResponse
from rvc.modules.uvr5.modules import UVR
from base64 import b64encode
from scipy.io import wavfile

router = APIRouter()


@router.post("/inference")
def uvr(
inputpath,
outputpath,
modelname,
res_type: str = Query("blob", enum=["blob", "json"]),
):
arries = [i for i in UVR()(inputpath, outputpath, model_name=modelname)]
wavfile.write(wv := BytesIO(), tgt_sr, audio_opt)
if res_type == "blob":
return responses.StreamingResponse(
wv,
media_type="audio/wav",
headers={"Content-Disposition": "attachment; filename=inference.wav"},
)
else:
return JSONResponse(
{
"audio": b64encode(wv.read()).decode("utf-8"),
}
)
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"},
)
5 changes: 1 addition & 4 deletions rvc/wrapper/cli/handler/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import click
from dotenv import load_dotenv
from scipy.io import wavfile
import torch

logging.getLogger("numba").setLevel(logging.WARNING)

Expand Down Expand Up @@ -130,6 +129,4 @@ def infer(
wavfile.write(outputpath, tgt_sr, audio_opt)
click.echo(times)
click.echo(f"Finish inference. Check {outputpath}")

if torch.cuda.is_available():
torch.cuda.empty_cache()
return tgt_sr, audio_opt, times
5 changes: 4 additions & 1 deletion rvc/wrapper/cli/handler/uvr5.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@
help="output Format",
)
def uvr(modelname, inputpath, outputpath, format):
UVR()(inputpath, outputpath, model_name=modelname, export_format=format)
uvr_module = UVR()
uvr_module.uvr_wrapper(
inputpath, outputpath, model_name=modelname, export_format=format
)
click.echo(f"Finish uvr5. Check {outputpath}")

0 comments on commit e02e007

Please sign in to comment.