# Whisper ASR Box

> A Dockerised REST API in front of Whisper, faster-whisper and WhisperX, with SRT/VTT output, word timestamps, VAD and diarization

- Category: Multimodal Generation / Audio, Music & Voice
- Language: Python
- Licence: MIT
- Repository: https://github.com/ahmetoner/whisper-asr-webservice
- Website: https://ahmetoner.github.io/whisper-asr-webservice
- Canonical page: https://ai-tldr.dev/tools/whisper-asr-box/

## In short

Whisper ASR Box (the `whisper-asr-webservice` project) turns Whisper into a service you can call. It sits in the Audio, Music & Voice category of the Multimodal Generation tools and is open-source, written in Python and licensed MIT. To get started: run it on CPU.

## Overview

Whisper ASR Box (the `whisper-asr-webservice` project) turns Whisper into a service you can call. Instead of wiring a Python transcription script into your app, you run one container and POST audio to a REST endpoint, getting back text, JSON, VTT, SRT or TSV. The image bundles FFmpeg, so it accepts the broad range of audio and video formats FFmpeg can read rather than just WAV.

Three engines sit behind the same API and are selected with an environment variable: `openai_whisper` (the reference implementation), `faster_whisper` (the CTranslate2 reimplementation, for throughput) and `whisperx` (which adds forced alignment and speaker diarization). The v1.10.0 release pins openai/whisper v20250625, faster-whisper v1.2.1 and whisperX v3.4.5, so you know exactly which upstream versions you are getting. Beyond engine choice, the environment variables cover the model size (`ASR_MODEL`, tiny through large-v3), a custom model path, device selection, and a `MODEL_IDLE_TIMEOUT` that unloads the model when it is idle — useful when a GPU is shared.

Operationally it is designed to be boring: word-level timestamps and voice-activity-detection filtering are built in, GPU acceleration is a second image tag plus `--gpus all`, and mounting a cache volume avoids re-downloading weights on every container start. The service publishes Swagger documentation at its root, so the endpoints are explorable from a browser before you write any client code. For local development the project uses Poetry with `cpu` and `cuda` extras. MIT-licensed.

## What it does

- One REST API over three engines — OpenAI Whisper, faster-whisper and WhisperX — selected by the ASR_ENGINE variable
- Output as text, JSON, VTT, SRT or TSV, with word-level timestamps
- Voice activity detection filtering, and speaker diarization when running the WhisperX engine
- FFmpeg bundled, so most audio and video container formats are accepted directly
- Separate CPU and GPU image tags; GPU needs only --gpus all
- MODEL_IDLE_TIMEOUT unloads an idle model, and ASR_MODEL_PATH plus a mounted cache volume keep weights off the critical path
- Swagger UI served at the root for exploring and trying the endpoints

## Getting started

The published Docker image is the intended way to run it; port 9000 serves both the API and its Swagger UI.

1. Run it on CPU

   Pick the engine and model size with environment variables.

```bash
docker run -d -p 9000:9000 \
  -e ASR_MODEL=base \
  -e ASR_ENGINE=openai_whisper \
  onerahmet/openai-whisper-asr-webservice:latest
```

2. Or on a GPU

   The -gpu tag plus --gpus all is the only difference.

```bash
docker run -d --gpus all -p 9000:9000 \
  -e ASR_MODEL=base \
  -e ASR_ENGINE=openai_whisper \
  onerahmet/openai-whisper-asr-webservice:latest-gpu
```

3. Persist the model cache

   Mounting the cache directory stops the container re-downloading weights on every start.

```bash
docker run -d -p 9000:9000 \
  -v $PWD/cache:/root/.cache/ \
  onerahmet/openai-whisper-asr-webservice:latest
```

4. Open the Swagger UI

   Visit the service root to read the endpoint documentation and try a transcription from the browser.

```text
http://localhost:9000
```

5. Run from source instead

   Poetry v2.x with the cpu or cuda extra, then start the service directly.

```bash
pip3 install poetry
poetry install --extras cpu     # or --extras cuda
poetry run whisper-asr-webservice --host 0.0.0.0 --port 9000
```

## When to use it

- Give an existing application transcription over HTTP without embedding a Python ML stack in it
- Produce SRT or VTT subtitles for a video library in batch, straight from the container
- Switch between reference Whisper, faster-whisper and WhisperX for accuracy-versus-throughput tests without changing client code
- Get diarized transcripts of multi-speaker recordings by selecting the WhisperX engine
- Share one GPU between services by letting an idle model unload on a timeout
