From 5bc2e260ff0f14a9a506a49899882e43769d4b1b Mon Sep 17 00:00:00 2001 From: Kar l5 Date: Sat, 14 Jun 2025 23:23:21 +0530 Subject: [PATCH] no need to download model --- Dockerfile | 5 +---- app/main.py | 10 +++++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 65126ef..fa7b88e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/app/main.py b/app/main.py index 5010757..a9ea22d 100644 --- a/app/main.py +++ b/app/main.py @@ -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}