mirror of
https://github.com/bellingcat/whisperbox-transcribe.git
synced 2026-06-12 05:28:34 +03:00
feat: simplify docker files
This commit is contained in:
2
.env.dev
2
.env.dev
@@ -1,5 +1,5 @@
|
||||
API_SECRET="a_very_secret_token"
|
||||
DOMAIN="whisperbox-transcribe.localhost"
|
||||
TRAEFIK_DOMAIN="whisperbox-transcribe.localhost"
|
||||
WHISPER_MODEL="tiny"
|
||||
ENVIRONMENT="development"
|
||||
DATABASE_URI="sqlite:///./whisperbox-transcribe.sqlite"
|
||||
|
||||
17
README.md
17
README.md
@@ -4,30 +4,33 @@
|
||||
|
||||
## Overview
|
||||
|
||||
This project wraps OpenAI's `whisper` models with a simple HTTP API. It is assumed that the service is used by exactly one consumer, so a pre-shared API key is used as authentication.
|
||||
This project wraps OpenAI's `whisper` speech-to-text models with a HTTP API.
|
||||
|
||||
The API design takes inspiration from the [rev.ai async speech-to-text API](https://docs.rev.ai/api/asynchronous/get-started/). Transcription jobs are submitted via a `HTTP POST`, returning an internal reference, which can later be used to retrieve the transcription results. Results are stored in an internal database until retrieved, and can optionally be deleted afterwards.
|
||||
The API design takes inspiration from the [rev.ai async speech-to-text API](https://docs.rev.ai/api/asynchronous/get-started/). Transcription jobs are submitted via a HTTP `POST` request. After the job is accepted, an id is returned, which can later be used to retrieve the transcription results from the service. Results are stored in an internal database until retrieved, and can optionally be deleted afterwards.
|
||||
|
||||
OpenAPI documentation for the service is available at `<service_url>/docs`.
|
||||
It is assumed that the service is used by exactly one consumer, so a pre-shared API key is used as authentication method. OpenAPI documentation for the service is available at `<service_url>/docs`.
|
||||
|
||||
## Deploy
|
||||
|
||||
### 0. Choose model & instance size
|
||||
|
||||
Whisper provides [several sizes](https://github.com/openai/whisper#available-models-and-languages) of their model, where model size is a trade-off between model accuracy, resource usage and transcription speed. Smaller models are generally faster and lighter, but more inaccurate, especially for certain languages and translation tasks.
|
||||
Whisper provides [several sizes](https://github.com/openai/whisper#available-models-and-languages) of their model where size is a trade-off between model accuracy, resource usage and transcription speed. Smaller models are generally faster and lighter, but more inaccurate, especially for non-english languages and translation tasks.
|
||||
|
||||
Whisper inference can be run on both CPU and GPU, and this project supports both via slightly altered docker compose configuration. (see GPU support section) CPU inference is a lot slower, but easier to host. CPU inference generally scales well with CPU speed.
|
||||
Whisper inference can be run on both CPU and GPU, and this project supports both via slightly altered docker compose configurations. CPU inference is slower, but easier and cheaper to host. CPU inference, while overall slower than the GPU, generally scales well with CPU speed.
|
||||
|
||||
Another consideration when choosing an instance is disk size. In order to transcribe audio, it needs to be downloaded to a temporary folder before processing, so the HDD needs to have enough free space to allow for that. For some hosting environments (e.g. Digital Ocean), it can make sense to mount an additional disk in the VM instead of choosing a larger instance.
|
||||
Another consideration when choosing your instance is disk size. In order to transcribe media, it first needs to be downloaded to a temporary file, so the HDD needs to have enough free space to allow for that. For some hosting environments (e.g. Digital Ocean), it can make sense to mount an additional disk in the VM instead of choosing a larger instance.
|
||||
|
||||
As a baseline, the `small` model can run on a `4GB` Digital Ocean droplet, achieving roughly a 1-2x speedup over original audio when transcribing.
|
||||
|
||||
### 1. Prepare host environment
|
||||
|
||||
This project is intended to be run via [docker compose](https://docs.docker.com/compose/). To get started:
|
||||
1. [install](https://docs.docker.com/engine/install/) docker engine.
|
||||
1. [Install](https://docs.docker.com/engine/install/) docker engine.
|
||||
2. Clone this repository to the machine.
|
||||
|
||||
> **Note**
|
||||
> If you want to use the GPU, uncomment the sections tagged with _<GPU SUPPORT>_ in docker-compose.prod.yml
|
||||
|
||||
### 2. Configure service
|
||||
|
||||
2. Create an `.env` file from `.env.example` and configure it:
|
||||
|
||||
@@ -22,6 +22,7 @@ services:
|
||||
memory: 128M
|
||||
|
||||
worker:
|
||||
env_file: .env
|
||||
build:
|
||||
context: .
|
||||
dockerfile: worker.Dockerfile
|
||||
@@ -39,6 +40,7 @@ services:
|
||||
retries: 5
|
||||
|
||||
web:
|
||||
env_file: .env
|
||||
build:
|
||||
context: .
|
||||
dockerfile: web.Dockerfile
|
||||
|
||||
@@ -1,22 +1,17 @@
|
||||
version: "3.8"
|
||||
name: whisperbox-transcribe-dev
|
||||
|
||||
services:
|
||||
traefik:
|
||||
container_name: whisperbox-transcribe_traefik_dev
|
||||
ports:
|
||||
- "80:80"
|
||||
command:
|
||||
- "--providers.docker=true"
|
||||
- "--providers.docker.exposedbydefault=false"
|
||||
- "--providers.docker.network=whisperbox-transcribe_traefik"
|
||||
- "--providers.docker.network=whisperbox-transcribe-dev_traefik"
|
||||
- "--entrypoints.web.address=:80"
|
||||
|
||||
redis:
|
||||
container_name: whisperbox-transcribe_redis_dev
|
||||
|
||||
web:
|
||||
container_name: whisperbox-transcribe_web_dev
|
||||
env_file: .env
|
||||
command: bash -c "alembic upgrade head && uvicorn app.web.main:app --reload --host ${HOST:-0.0.0.0} --port ${PORT:-8000} --log-level info"
|
||||
volumes:
|
||||
- ./:/etc/whisperbox-transcribe/
|
||||
@@ -27,14 +22,11 @@ services:
|
||||
- "traefik.http.routers.web.rule=(Host(`${TRAEFIK_DOMAIN}`))"
|
||||
|
||||
worker:
|
||||
container_name: whisperbox-transcribe_worker_dev
|
||||
env_file: .env
|
||||
command: watchmedo auto-restart -d app/worker -p *.py --recursive celery -- --app=app.worker.main.celery worker --loglevel=info --concurrency=1 --pool solo
|
||||
volumes:
|
||||
- ./:/etc/whisperbox-transcribe/
|
||||
|
||||
flower:
|
||||
container_name: whisperbox-transcribe_flower_dev
|
||||
image: mher/flower
|
||||
command: celery --broker redis://redis:6379/0 flower --port=5555
|
||||
ports:
|
||||
@@ -44,4 +36,3 @@ services:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- app
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
version: "3.8"
|
||||
name: whisperbox-transcribe
|
||||
|
||||
services:
|
||||
traefik:
|
||||
container_name: whisperbox-transcribe_traefik
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
@@ -22,12 +22,7 @@ services:
|
||||
- ./data/letsencrypt:/letsencrypt
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
redis:
|
||||
container_name: whisperbox-transcribe_redis
|
||||
|
||||
worker:
|
||||
container_name: whisperbox-transcribe_worker
|
||||
env_file: .env
|
||||
# <GPU SUPPORT>
|
||||
# build:
|
||||
# dockerfile: worker.gpu.Dockerfile
|
||||
@@ -43,8 +38,6 @@ services:
|
||||
# capabilities: [gpu]
|
||||
|
||||
web:
|
||||
container_name: whisperbox-transcribe_web
|
||||
env_file: .env
|
||||
volumes:
|
||||
- whisperbox-transcribe-data:/etc/whisperbox-transcribe/data/
|
||||
labels:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# TODO: clean up lol
|
||||
# TODO: clean up
|
||||
FROM nvidia/cuda:11.8.0-base-ubuntu22.04 AS python-deploy
|
||||
|
||||
ENV PYTHON_VERSION=3.10
|
||||
|
||||
Reference in New Issue
Block a user