Spaces:
Build error
Build error
Kartikeyssj2
commited on
Upload 4 files
Browse files- Dockerfile +14 -0
- download_models.py +0 -0
- fast_api.py +26 -0
- trasncribe.py +0 -0
Dockerfile
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.12.3-slim
|
2 |
+
|
3 |
+
WORKDIR /app
|
4 |
+
|
5 |
+
COPY requirements.txt .
|
6 |
+
|
7 |
+
RUN pip install --upgrade pip \
|
8 |
+
&& pip install -r requirements.txt
|
9 |
+
|
10 |
+
COPY . .
|
11 |
+
|
12 |
+
|
13 |
+
# Use 4 worker processes to handle requests efficiently.
|
14 |
+
CMD ["gunicorn", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "fast_api:app"]
|
download_models.py
ADDED
File without changes
|
fast_api.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import whisper
|
2 |
+
from fastapi import FastAPI, UploadFile, File
|
3 |
+
from pydantic import BaseModel
|
4 |
+
|
5 |
+
model = whisper.load_model("tiny")
|
6 |
+
|
7 |
+
app = FastAPI()
|
8 |
+
|
9 |
+
|
10 |
+
def transcribe(audio_file_path: str, model):
|
11 |
+
# Load audio and run inference
|
12 |
+
result = model.transcribe(audio_file_path)
|
13 |
+
return result["text"]
|
14 |
+
|
15 |
+
@app.post("/transcribe")
|
16 |
+
async def transcribe_audio(file: UploadFile = File(...)):
|
17 |
+
|
18 |
+
# SAVE THE UPLOAD FILE TEMPORARILY
|
19 |
+
with open(file.filename, "wb") as buffer:
|
20 |
+
|
21 |
+
buffer.write(await file.read())
|
22 |
+
|
23 |
+
# TRANSCRIBE THE AUDIO
|
24 |
+
transcription = transcribe(file.filename, model)
|
25 |
+
|
26 |
+
return { "transcription" : transcription }
|
trasncribe.py
ADDED
File without changes
|