import whisper import time from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() @app.get("/") def read_main(): return {"message": "This is your main app"} class Response(BaseModel): path: str model = whisper.load_model("medium") @app.post("/voice2txt/") def calculate_api(response: Response): path = response.path result = model.transcribe(path)["text"] return {"message": result}