no need to download model

This commit is contained in:
Kar
2025-06-14 23:23:21 +05:30
parent 16aa10ad82
commit 5bc2e260ff
2 changed files with 6 additions and 9 deletions

View File

@@ -1,12 +1,12 @@
from fastapi import FastAPI, File, UploadFile
import os
import shutil
import os
from whispercpp import Whisper
app = FastAPI()
# Load model using the updated API
whisper = Whisper.from_pretrained("./app/model/ggml-base.en.bin")
# Load the model (auto-download and cache it)
whisper = Whisper.from_pretrained("base.en") # Options: tiny, base, small, etc.
@app.post("/transcribe")
async def transcribe_audio(audio: UploadFile = File(...)):
@@ -14,6 +14,6 @@ async def transcribe_audio(audio: UploadFile = File(...)):
with open(temp_file, "wb") as buffer:
shutil.copyfileobj(audio.file, buffer)
text = whisper.transcribe(temp_file)
result = whisper.transcribe(temp_file)
os.remove(temp_file)
return {"text": text}
return {"text": result}