Drop-in replacement for the OpenAI's Whisper API using the same API but running locally.
Modified from https://github.com/morioka/tiny-openai-whisper-api.
Install Docker, then run:
docker build -t didmar/whisper-api-server .
docker run -d -p 127.0.0.1:8000:8000 -v .cache:/root/.cache:rw didmar/whisper-api-server --workers 1
# Customize number of workers is needs to handle multiple requests in parallel
Or use Docker compose:
docker compose up --build -d
Requires python >= 3.10, pip and virtualenv.
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
python3 main.py
Check out the API documentation at http://localhost:8000/docs.
For example:
curl -sSfLO https://upload.wikimedia.org/wikipedia/commons/2/2b/American_English_sound_%22h%22_%28female%29.wav
curl --request POST \
--url "http://localhost:8000/v1/audio/transcriptions" \
--header 'Content-Type: multipart/form-data' \
--form file=@American_English_sound_%22h%22_%28female%29.wav \
--form model=whisper-1
# {"text":" Hot hole high. Hu. Hu. Hu. Behind. Hu. Hu."}
We use Poetry to manage dependencies, Ruff for linting and Black for formatting.
The poetry.lock
file is committed to the repository.
When adding a new dependency, use poetry add <package>
and commit the updated poetry.lock
file.
If the dependency is only needed for development, add the --dev
flag.
# Automatically update the dependencies to the latest compatible version
poetry update
# Use the export commands to update the frozen requirements files
poetry export -f requirements.txt --output requirements.txt
poetry export --only dev -f requirements.txt --output dev-requirements.txt
# Setup pre-commit hooks (See https://pre-commit.com/)
pre-commit install