Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM python:3.10

# Pre-download Whisper model using ADD
ARG WHISPER_MODEL_URL=https://openaipublic.azureedge.net/main/whisper/models/345ae4da62f9b3d59415adc60127b97c714f32e89e936602e85993674d08dcb1/medium.pt
ARG WHISPER_MODEL=medium
RUN mkdir -p /root/.cache/whisper
ADD ${WHISPER_MODEL_URL} /root/.cache/whisper/${WHISPER_MODEL}.pt

# Remove apt auto-clean hook to preserve cache
RUN rm -f /etc/apt/apt.conf.d/docker-clean

Expand All @@ -17,13 +23,11 @@ WORKDIR /app
COPY pyproject.toml uv.lock ./

# Install dependencies with cache mount
ENV UV_LINK_MODE=copy
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked

# Copy application code
COPY . .

# Pre-download Whisper model to avoid runtime download
RUN uv run python -c "import whisper; whisper.load_model('medium')"

CMD ["uv", "run", "python", "app.py"]
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ git clone https://github.com/NINAnor/whisperUI
docker build -t whisperui -f Dockerfile .
```

To build with a different Whisper model:

```bash
# Get the model URL using the tool
WHISPER_MODEL_URL=$(uv run python utils/get_model_url.py medium)

# Build with custom model
docker build \
--build-arg WHISPER_MODEL_URL=$WHISPER_MODEL_URL \
--build-arg WHISPER_MODEL=medium \
-t whisperui .
```

Available models: `tiny`, `base`, `small`, `medium`, `large-v1`, `large-v2`, `large-v3`, `turbo`
(Also available with `.en` suffix for English-only versions)

Run the application on `localhost`:

```
Expand Down
21 changes: 21 additions & 0 deletions utils/get_model_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python3
"""
Tool to print Whisper model URLs for Docker builds.
Usage: python get_model_url.py [model_name]
"""
import sys
import whisper

def main():
model_name = sys.argv[1] if len(sys.argv) > 1 else "medium"

try:
url = whisper._MODELS[model_name]
print(url)
except KeyError:
print(f"Error: Model '{model_name}' not found.", file=sys.stderr)
print("Available models:", ", ".join(whisper.available_models()), file=sys.stderr)
sys.exit(1)

if __name__ == "__main__":
main()
Loading