no need to download model

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

View File

@ -6,15 +6,12 @@ RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy app and download model
COPY app ./app
COPY download-model.sh .
RUN chmod +x download-model.sh && ./download-model.sh
EXPOSE 4002
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "4002"]

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}