fix file uploads
This commit is contained in:
parent
6a5c071fe1
commit
b9bdf1b86e
12
api.py
12
api.py
@ -1,11 +1,11 @@
|
||||
from fastapi import FastAPI, Response, UploadFile
|
||||
from fastapi import FastAPI, File, Query, Response, UploadFile
|
||||
from fastapi.encoders import jsonable_encoder
|
||||
from fastapi.responses import FileResponse
|
||||
from config import TOKEN
|
||||
import hmac
|
||||
import model
|
||||
from pydantic import BaseModel
|
||||
from typing import List, Optional
|
||||
from typing import Annotated, List, Optional
|
||||
import tempfile
|
||||
|
||||
from rvc.main import song_cover_pipeline
|
||||
@ -33,16 +33,16 @@ async def root(token: str,
|
||||
|
||||
@app.post("/rvc")
|
||||
async def rvc(token: str,
|
||||
file: UploadFile,
|
||||
file: Annotated[bytes, File()],
|
||||
response: Response,
|
||||
pitch_change_oct: Optional[int] = 1,
|
||||
pitch_change_sem: Optional[int] = 0):
|
||||
pitch_change_oct: Annotated[int, Query()] = 1,
|
||||
pitch_change_sem: Annotated[int, Query()] = 0):
|
||||
if not hmac.compare_digest(token, TOKEN):
|
||||
response.status_code = 401
|
||||
return {"error": "Bad token"}
|
||||
|
||||
with tempfile.NamedTemporaryFile() as tmp:
|
||||
tmp.write(await file.read())
|
||||
tmp.write(file)
|
||||
ai_vocals_path = song_cover_pipeline(tmp.name, pitch_change_oct, voice_model='miku', pitch_change_sem=pitch_change_sem)
|
||||
|
||||
return FileResponse(ai_vocals_path)
|
||||
|
@ -9,6 +9,7 @@ onnxruntime_gpu
|
||||
praat-parselmouth>=0.4.2
|
||||
#pedalboard==0.7.7
|
||||
#pydub==0.25.1
|
||||
python-multipart==0.0.9
|
||||
pyworld==0.3.4
|
||||
#Requests==2.31.0
|
||||
scipy==1.11.1
|
||||
|
Loading…
x
Reference in New Issue
Block a user