Whisper ASR Webservice

repository·main·Indexed 25 days ago

https://github.com/ahmetoner/whisper-asr-webservice

A general-purpose speech recognition webservice providing a REST API for multilingual speech recognition, translation, and language identification. It supports multiple engines including openai_whisper, faster_whisper, and whisperx, and offers features such as speaker diarization, word-level timestamps, and various output formats (text, json, vtt, srt, tsv). The service can be deployed via Docker or Docker Compose on both CPU and GPU.

Tokens
4.2K
Snippets
24
Records
39
Agent score
85%

What's inside whisper-asr-webservice

  1. Run Whisper ASR Box using Docker (CPU)

    main

    To run the service on a CPU, use the latest Docker image. You can specify the model and engine using environment variables.

    docker run -d -p 9000:9000 \
      -e ASR_MODEL=base \
      -e ASR_ENGINE=openai_whisper \
      onerahmet/openai-whisper-asr-webservice:latest
  2. Configure CUDA support for PyTorch

    main

    By default, poetry install installs the CPU version of PyTorch. If you require GPU support, you must manually install the appropriate CUDA version of PyTorch.

    Example for CUDA 12.1 (adjust the index URL and version as needed for your specific CUDA version, e.g., 11.8):

    pip3 install torch==2.6.0 --index-url https://download.pytorch.org/whl/cu121
  3. Run Whisper ASR Webservice using Docker (CPU)

    main

    To run the service on CPU (including macOS), pull the latest image and run the container. Note that on macOS, GPU passthrough is not supported due to Docker's Linux VM architecture; use the CPU image instead. The :latest tag supports both amd64 and arm64 architectures.

    docker pull onerahmet/openai-whisper-asr-webservice:latest
    docker run -d -p 9000:9000 \
      -e ASR_MODEL=base \
      -e ASR_ENGINE=openai_whisper \
      onerahmet/openai-whisper-asr-webservice:latest
  4. Build and run Whisper ASR Webservice with Docker (GPU)

    main

    Use Dockerfile.gpu to build the GPU-enabled image. When running the container, you must use the --gpus all flag to grant access to the host's GPU.

    # Build Image
    docker build -f Dockerfile.gpu -t whisper-asr-webservice-gpu .
    
    # Run Container
    docker run -d --gpus all -p 9000:9000 whisper-asr-webservice-gpu
    
    # Run Container with a specific model (e.g., base)
    docker run -d --gpus all -p 9000:9000 -e ASR_MODEL=base whisper-asr-webservice-gpu
  5. Build and run Whisper ASR Webservice with Docker (CPU)

    main

    Use the standard Dockerfile to build and run the CPU version of the service.

    # Build Image
    docker build -t whisper-asr-webservice .
    
    # Run Container
    docker run -d -p 9000:9000 whisper-asr-webservice
    
    # Run Container with a specific model (e.g., base)
    docker run -d -p 9000:9000 -e ASR_MODEL=base whisper-asr-webservice
  6. Run Whisper ASR Web Service using CPU

    main

    To run the Whisper ASR Web Service on a CPU-only environment, use the following Docker command. This maps port 9000 and sets the model to base using the openai_whisper engine.

    docker run -d -p 9000:9000 -e ASR_MODEL=base -e ASR_ENGINE=openai_whisper onerahmet/openai-whisper-asr-webservice:latest
  7. Set up Whisper ASR Box for Development

    main

    To develop locally, install poetry, install the appropriate dependencies (CPU or CUDA), and run the service using poetry run.

    # Install poetry v2.X
    pip3 install poetry
    
    # Install dependencies for cpu
    poetry install --extras cpu
    
    # Install dependencies for cuda
    poetry install --extras cuda
    
    # Run service
    poetry run whisper-asr-webservice --host 0.0.0.0 --port 9000