14
.env
14
.env
@@ -1,14 +0,0 @@
|
|||||||
OPENBLAS_NUM_THREADS = 1
|
|
||||||
no_proxy = localhost, 127.0.0.1, ::1
|
|
||||||
|
|
||||||
# You can change the location of the model, etc. by changing here
|
|
||||||
weight_root = /Users/ftps/Retrieval-based-Voice-Conversion-WebUI/assets/weights
|
|
||||||
weight_uvr5_root = /Users/ftps/Retrieval-based-Voice-Conversion-WebUI/assets/uvr5_weights
|
|
||||||
index_root = /Users/ftps/Retrieval-based-Voice-Conversion-WebUI/logs
|
|
||||||
rmvpe_root = /Users/ftps/Retrieval-based-Voice-Conversion-WebUI/assets/rmvpe
|
|
||||||
hubert_path = /Users/ftps/Retrieval-based-Voice-Conversion-WebUI/assets/hubert/hubert_base.pt
|
|
||||||
hubert_path_ = /Users/ftps/Downloads/Hubert Base.pt
|
|
||||||
save_uvr_path = /Users/ftps/Retrieval-based-Voice-Conversion-WebUI/opt
|
|
||||||
TEMP = /Users/ftps/Retrieval-based-Voice-Conversion-WebUI/TEMP
|
|
||||||
pretrained = /Users/ftps/Retrieval-based-Voice-Conversion-WebUI/assets/pretrained
|
|
||||||
exp_dir =
|
|
||||||
@@ -20,7 +20,7 @@ class UVR:
|
|||||||
self.need_reformat: bool = True
|
self.need_reformat: bool = True
|
||||||
self.config: Config = Config()
|
self.config: Config = Config()
|
||||||
|
|
||||||
def __call__(
|
def uvr_wrapper(
|
||||||
self,
|
self,
|
||||||
audio_path: Path,
|
audio_path: Path,
|
||||||
agg: int = 10,
|
agg: int = 10,
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ from base64 import b64encode
|
|||||||
from rvc.modules.vc.modules import VC
|
from rvc.modules.vc.modules import VC
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
import torch
|
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
@@ -44,6 +43,7 @@ def inference(
|
|||||||
rms_mix_rate: float = 0.25,
|
rms_mix_rate: float = 0.25,
|
||||||
protect: float = 0.33,
|
protect: float = 0.33,
|
||||||
):
|
):
|
||||||
|
print(res_type)
|
||||||
vc = VC()
|
vc = VC()
|
||||||
vc.get_vc(modelpath)
|
vc.get_vc(modelpath)
|
||||||
tgt_sr, audio_opt, times, _ = vc.vc_inference(
|
tgt_sr, audio_opt, times, _ = vc.vc_inference(
|
||||||
@@ -61,10 +61,6 @@ def inference(
|
|||||||
)
|
)
|
||||||
wavfile.write(wv := BytesIO(), tgt_sr, audio_opt)
|
wavfile.write(wv := BytesIO(), tgt_sr, audio_opt)
|
||||||
print(times)
|
print(times)
|
||||||
|
|
||||||
if torch.cuda.is_available():
|
|
||||||
torch.cuda.empty_cache()
|
|
||||||
|
|
||||||
if res_type == "blob":
|
if res_type == "blob":
|
||||||
return responses.StreamingResponse(
|
return responses.StreamingResponse(
|
||||||
wv,
|
wv,
|
||||||
|
|||||||
@@ -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 rvc.modules.uvr5.modules import UVR
|
||||||
from base64 import b64encode
|
|
||||||
from scipy.io import wavfile
|
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
@router.post("/inference")
|
@router.post("/inference")
|
||||||
def uvr(
|
def uvr(inputpath, outputpath, modelname, format):
|
||||||
inputpath,
|
uvr_module = UVR()
|
||||||
outputpath,
|
uvr_module.uvr_wrapper(
|
||||||
modelname,
|
inputpath, outputpath, model_name=modelname, export_format=format
|
||||||
res_type: str = Query("blob", enum=["blob", "json"]),
|
)
|
||||||
):
|
return responses.StreamingResponse(
|
||||||
arries = [i for i in UVR()(inputpath, outputpath, model_name=modelname)]
|
audio,
|
||||||
wavfile.write(wv := BytesIO(), tgt_sr, audio_opt)
|
media_type="audio/wav",
|
||||||
if res_type == "blob":
|
headers={"Content-Disposition": "attachment; filename=inference.wav"},
|
||||||
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"),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ from pathlib import Path
|
|||||||
import click
|
import click
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from scipy.io import wavfile
|
from scipy.io import wavfile
|
||||||
import torch
|
|
||||||
|
|
||||||
logging.getLogger("numba").setLevel(logging.WARNING)
|
logging.getLogger("numba").setLevel(logging.WARNING)
|
||||||
|
|
||||||
@@ -130,6 +129,4 @@ def infer(
|
|||||||
wavfile.write(outputpath, tgt_sr, audio_opt)
|
wavfile.write(outputpath, tgt_sr, audio_opt)
|
||||||
click.echo(times)
|
click.echo(times)
|
||||||
click.echo(f"Finish inference. Check {outputpath}")
|
click.echo(f"Finish inference. Check {outputpath}")
|
||||||
|
return tgt_sr, audio_opt, times
|
||||||
if torch.cuda.is_available():
|
|
||||||
torch.cuda.empty_cache()
|
|
||||||
|
|||||||
@@ -38,5 +38,8 @@ from rvc.modules.uvr5.modules import UVR
|
|||||||
help="output Format",
|
help="output Format",
|
||||||
)
|
)
|
||||||
def uvr(modelname, inputpath, outputpath, 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}")
|
click.echo(f"Finish uvr5. Check {outputpath}")
|
||||||
|
|||||||
Reference in New Issue
Block a user