Spaces:
Configuration error
Configuration error
import whisper | |
from fastapi import FastAPI, UploadFile, File | |
from fastapi.responses import JSONResponse | |
model = whisper.load_model("base") | |
app = FastAPI() | |
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"]}) | |