no need to download model
parent
16aa10ad82
commit
5bc2e260ff
|
@ -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"]
|
||||
|
|
10
app/main.py
10
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}
|
||||
|
|
Loading…
Reference in New Issue