W
Whisper API
Navigation

This guide walks you through setting up the Whisper API from scratch on your local machine.

Prerequisites

Before you begin, make sure you have the following installed:

RequirementVersionPurpose
Python3.10+Runtime for the FastAPI server
pipLatestPython package manager
FFmpegAnyAudio transcoding to 16kHz WAV
GitAnyClone the repository
CMake3.14+Build whisper.cpp from source
C++ Compilerg++ or clang++Compile the whisper binary

Installation

    1. Clone the Repository

      git clone https://github.com/innovatorved/whisper.api.git
      cd whisper.api
    2. Create a Virtual Environment (recommended)

      venv

      python -m venv .venv
      source .venv/bin/activate

      conda

      conda create -n whisper python=3.10
      conda activate whisper
    3. Install Python Dependencies

      pip install -r requirements.txt
    4. Configure Environment Variables

      Copy the example file and customize:

      cp .env.example .env

      Key variables:

      # Security — change this in production!
      SECRET_KEY=your-secret-key-here
      
      # Server
      SERVER_HOST=http://localhost:7860
      
      # Database
      DATABASE_URL=sqlite:///./whisper.db
      
      # Whisper binary & models
      WHISPER_BINARY_PATH=./binary/whisper-cli
      MODELS_DIR=./models
      
      # Concurrency
      MAX_CONCURRENT_TRANSCRIPTIONS=2
      
      # Streaming chunk size (ms)
      STREAM_CHUNK_DURATION_MS=5000
    5. Build the whisper.cpp Binary

      The setup script clones, builds, and installs the whisper-cli binary:

      chmod +x setup_whisper.sh
      ./setup_whisper.sh
    6. Initialize the Database & Create an API Key

      python -m app.cli init
      python -m app.cli create --name "MyFirstKey"

      Save the generated token — you’ll need it for all API requests.

    7. Start the Server

      uvicorn app.main:app --host 0.0.0.0 --port 7860 --reload

Verify Your Installation

Once the server is running, verify it works:

Health Check

curl http://localhost:7860/ping

Expected response:

{ "ping": "pong", "status": "healthy" }

Swagger UI

Open http://localhost:7860/docs in your browser to access the interactive API documentation.

First Transcription

curl -X POST 'http://localhost:7860/v1/listen' \
  -H "Authorization: Token YOUR_API_KEY" \
  -H "Content-Type: audio/wav" \
  --data-binary @audio/jfk.wav

Environment Variables Reference

VariableDefaultDescription
SECRET_KEYRequired. Secret for token hashing
SERVER_HOSThttp://localhost:7860Public server URL
DATABASE_URLsqlite:///./whisper.dbSQLAlchemy database connection string
WHISPER_BINARY_PATH./binary/whisper-cliPath to the compiled whisper-cli binary
MODELS_DIR./modelsDirectory containing .bin model files
MAX_CONCURRENT_TRANSCRIPTIONS2Max parallel transcription processes
STREAM_CHUNK_DURATION_MS5000Streaming buffer duration in milliseconds
ENABLE_TEST_TOKEN_ENDPOINTfalseEnable /v1/auth/test-token in Swagger
BACKEND_CORS_ORIGINS[]Allowed CORS origins (JSON array)

Next Steps