Raphastein's picture
Update app.py
86e87b1 verified
raw
history blame contribute delete
448 Bytes
import whisper
from fastapi import FastAPI, UploadFile, File
from fastapi.responses import JSONResponse
model = whisper.load_model("base")
app = FastAPI()
@app.post("/upload")
async def upload_audio(file: UploadFile = File(...)):
file_location = "/tmp/temp.wav"
with open(file_location, "wb") as f:
f.write(await file.read())
result = model.transcribe(file_location)
return JSONResponse(content={"text": result["text"]})