Sign inSign up

evilfreelancer/whisper-server

By evilfreelancer

Updated over 1 year ago

Whisper.cpp HTTP transcription server with OAI-like API in Docker.

Image
Machine learning & AI
1

3.1K

evilfreelancer/whisper-server repository overview

Whisper.cpp API Webserver in Docker

Whisper.cpp HTTP transcription server with OAI-like API in Docker.

This project provides a Dockerized transcription server based on whisper.cpp.

Русский | 中文 | English

Features

  • Dockerized whisper.cpp HTTP server for audio transcription
  • Configurable via environment variables
  • Automatically converts audio to WAV format
  • Automatically downloads required model on startup
  • Can quantize any Whisper model to the required type on startup

Requirements

Before you begin, ensure you have a machine with an GPU that supports modern CUDA, due to the computational demands of the docker image.

  • Nvidia GPU / Intel Arc
  • CUDA / oneAPI
  • Docker
  • Docker Compose
  • Nvidia Docker Runtime (Nvidia only)

For detailed instructions on how to prepare a Linux machine for running neural networks, including the installation of CUDA, Docker, and Nvidia Docker Runtime, please refer to the publication "How to Prepare Linux for Running and Training Neural Networks? (+ Docker)" on Russian.

Installation

  1. Clone the repo and switch to sources root:

    git clone https://github.com/EvilFreelancer/docker-whisper-server.git
    cd docker-whisper-server
    
  2. Copy the provided Docker Compose template:

    cp docker-compose.dist.yml docker-compose.yml
    

Example for Intel Arc cards:

x-shared-logs: &shared-logs
   logging:
      driver: "json-file"
      options:
         max-size: "10k"

services:
  whisper-intel:
    restart: "unless-stopped"
    build:
      context: ./whisper
      dockerfile: Dockerfile.intel  
      args:
        - WHISPER_VERSION=v1.7.4
    devices:
       - /dev/dri
    volumes:
      - ./models:/app/models
    ports:
      - "127.0.0.1:9000:9000"
    environment:
      WHISPER_MODEL: large-v3-turbo
      WHISPER_MODEL_QUANTIZATION: q4_0
    <<: *shared-logs
  1. Build the Docker image:

    docker-compose build
    
  2. Start the services:

    docker-compose up -d
    
  3. Navigate to http://localhost:8080 in browser:

    Swagger UI

Endpoints

/inference

Transcribe an audio file:

curl 127.0.0.1:9000/inference \
  -H "Content-Type: multipart/form-data" \
  -F file="@<file-path>" \
  -F temperature="0.0" \
  -F temperature_inc="0.2" \
  -F response_format="json"
/load

Load a new Whisper model:

curl 127.0.0.1:9000/load \
   -H "Content-Type: multipart/form-data" \
   -F model="<path-to-model-file-in-docker-container>"

Environment variables

Basic configuration

NameDefaultDescription
WHISPER_MODELbase.enThe default Whisper model to use
WHISPER_MODEL_PATH/app/models/ggml-${WHISPER_MODEL}.binThe default path to the Whisper model file
WHISPER_MODEL_QUANTIZATIONLevel of quantization (will be applied only if WHISPER_MODEL_PATH not changed)
Advanced Configuration
NameDefaultDescription
WHISPER_THREADS4Number of threads to use for inference
WHISPER_PROCESSORS1Number of processors to use for inference
WHISPER_HOST0.0.0.0Host IP or hostname to bind the server to
WHISPER_PORT9000Port number to listen on
WHISPER_INFERENCE_PATH/inferenceInference path for all requests
WHISPER_PUBLIC_PATHPath to the public folder
WHISPER_REQUEST_PATHRequest path for all requests
WHISPER_OV_E_DEVICECPUOpenViBE Event Device to use
WHISPER_OFFSET_T0Time offset in milliseconds
WHISPER_OFFSET_N0Number of seconds to offset
WHISPER_DURATION0Duration of the audio file in milliseconds
WHISPER_MAX_CONTEXT-1Maximum context size for inference
WHISPER_MAX_LEN0Maximum length of output text
WHISPER_BEST_OF2Best-of-N strategy for inference
WHISPER_BEAM_SIZE-1Beam size for search
WHISPER_AUDIO_CTX0Audio context to use for inference
WHISPER_WORD_THOLD0.01Word threshold for segmentation
WHISPER_ENTROPY_THOLD2.40Entropy threshold for segmentation
WHISPER_LOGPROB_THOLD-1.00Log probability threshold for segmentation
WHISPER_LANGUAGEenLanguage code to use for translation or diarization
WHISPER_PROMPTInitial prompt
WHISPER_DTWCompute token-level timestamps
WHISPER_CONVERTtrueConvert audio to WAV, requires ffmpeg on the server
WHISPER_SPLIT_ON_WORDfalseSplit on word rather than on token
WHISPER_DEBUG_MODEfalseEnable debug mode
WHISPER_TRANSLATEfalseTranslate from source language to english
WHISPER_DIARIZEfalseStereo audio diarization
WHISPER_TINYDIARIZEfalseEnable tinydiarize (requires a tdrz model)
WHISPER_NO_FALLBACKfalseDo not use temperature fallback while decoding
WHISPER_PRINT_SPECIALfalsePrint special tokens
WHISPER_PRINT_COLORSfalsePrint colors
WHISPER_PRINT_REALTIMEfalsePrint output in realtime
WHISPER_PRINT_PROGRESSfalsePrint progress
WHISPER_NO_TIMESTAMPSfalseDo not print timestamps
WHISPER_DETECT_LANGUAGEfalseExit after automatically detecting language

Citing

[Pavel Rykov]. (2024). Whisper.cpp API Webserver in Docker. GitHub. https://github.com/EvilFreelancer/docker-whisper-server
@misc{pavelrykov2024whisperapi,
  author = {Pavel Rykov},
  title  = {Whisper.cpp API Webserver in Docker},
  year   = {2024},
  url    = {https://github.com/EvilFreelancer/docker-whisper-server}
}

Tag summary

Content type

Image

Digest

sha256:6992c668f

Size

1.7 GB

Last updated

over 1 year ago

docker pull evilfreelancer/whisper-server