File size: 448 Bytes
35d377d
5214799
 
2eb18b5
35d377d
5d4ddf5
2eb18b5
5d4ddf5
 
5214799
 
5d4ddf5
35d377d
5214799
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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"]})