abhinavvvvv's picture
changed the indic model to whisper small
981dc67
raw
history blame contribute delete
817 Bytes
from fastapi import FastAPI, UploadFile, File, HTTPException
from app.model import load_model
from app.audio import preprocess_audio
import os
app = FastAPI(title="Whisper Small ASR API")
asr_model = load_model()
@app.get("/")
def root():
return {"status": "running", "model": "whisper-small"}
@app.post("/transcribe")
async def transcribe(file: UploadFile = File(...)):
if not file.filename.endswith((".wav", ".mp3", ".m4a")):
raise HTTPException(status_code=400, detail="Unsupported file format")
try:
processed_audio = preprocess_audio(file)
result = asr_model(processed_audio)
os.remove(processed_audio)
return {
"transcription": result["text"]
}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))