code updated

This commit is contained in:
superobk
2024-04-09 12:00:08 +08:00
parent 41621b44f7
commit c104ea52b5
3 changed files with 12 additions and 2 deletions

10
main.py
View File

@ -8,9 +8,19 @@ from src.dotchain.runtime.tokenizer import Tokenizer
from src.dotchain.runtime.runtime import Runtime
from src.blackbox.blackbox_factory import BlackboxFactory
import uvicorn
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
blackbox_factory = BlackboxFactory()
@app.post("/")

View File

@ -38,4 +38,4 @@ class ASR(Blackbox):
txt = await self.processing(d)
except ValueError as e:
return JSONResponse(content={"error": str(e)}, status_code=status.HTTP_400_BAD_REQUEST)
return JSONResponse(content={"txt": txt}, status_code=status.HTTP_200_OK)
return JSONResponse(content={"text": txt}, status_code=status.HTTP_200_OK)

View File

@ -33,4 +33,4 @@ class AudioChat(Blackbox):
return JSONResponse(content={"error": "data is required"}, status_code=status.HTTP_400_BAD_REQUEST)
d = await data.read()
by = await self.processing(d)
return Response(content=by.read(), media_type="audio/wav", headers={"Content-Disposition": "attachment; filename=audio.wav"})
return Response(content=by.read(), media_type="audio/x-wav", headers={"Content-Disposition": "attachment; filename=audio.wav"})