Fixed rvc endpoint accepting files
This commit is contained in:
@@ -25,7 +25,7 @@ load_dotenv()
|
||||
|
||||
@router.post("/inference")
|
||||
def inference(
|
||||
input_audio: Path | UploadFile,
|
||||
input_audio: UploadFile,
|
||||
modelpath: Path
|
||||
| UploadFile = Body(
|
||||
...,
|
||||
@@ -49,21 +49,34 @@ def inference(
|
||||
protect: float = 0.33,
|
||||
):
|
||||
print(res_type)
|
||||
vc = VC()
|
||||
vc.get_vc(modelpath)
|
||||
tgt_sr, audio_opt, times, _ = vc.vc_inference(
|
||||
sid,
|
||||
input_audio,
|
||||
f0_up_key,
|
||||
f0_method,
|
||||
f0_file,
|
||||
index_file,
|
||||
index_rate,
|
||||
filter_radius,
|
||||
resample_sr,
|
||||
rms_mix_rate,
|
||||
protect,
|
||||
)
|
||||
|
||||
# Handle uploaded input_audio file
|
||||
tmp_input_audio = tempfile.NamedTemporaryFile(suffix=".wav", delete=False)
|
||||
input_bytes = input_audio.file.read()
|
||||
tmp_input_audio.write(input_bytes)
|
||||
tmp_input_audio.close()
|
||||
input_audio_path = tmp_input_audio.name
|
||||
|
||||
try:
|
||||
vc = VC()
|
||||
vc.get_vc(modelpath)
|
||||
tgt_sr, audio_opt, times, _ = vc.vc_inference(
|
||||
sid,
|
||||
input_audio_path,
|
||||
f0_up_key,
|
||||
f0_method,
|
||||
f0_file,
|
||||
index_file,
|
||||
index_rate,
|
||||
filter_radius,
|
||||
resample_sr,
|
||||
rms_mix_rate,
|
||||
protect,
|
||||
)
|
||||
finally:
|
||||
# Clean up temporary input audio file
|
||||
os.unlink(tmp_input_audio.name)
|
||||
|
||||
wavfile.write(wv := BytesIO(), tgt_sr, audio_opt)
|
||||
print(times)
|
||||
if res_type == "blob":
|
||||
|
||||
Reference in New Issue
Block a user