-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit 043fa4d.
- Loading branch information
Showing
6 changed files
with
18 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters