Skip to content
项目

ahmetoner/whisper-asr-webservice

在 GitHub 查看

关于

OpenAI Whisper 自动语音识别 Web 服务 API

人工智能与机器学习

这些数字如何统计

可以做什么

  • OpenAI-compatible API: works with the OpenAI SDKs and any application that lets you set the OpenAI base URL
  • Three engines: OpenAI Whisper, Faster Whisper and WhisperX
  • Transcription in every language Whisper supports, and translation into English
  • Language detection with a confidence score

实测星标增长

24小时
0
7天
0
15天
+2
1个月
+3

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

Whisper ASR Webservice

Release Docker Pulls Test License

A self-hosted REST API for speech recognition, translation and language identification based on OpenAI Whisper. It runs as a Docker container on CPU or NVIDIA GPU.

Features

  • OpenAI-compatible API: works with the OpenAI SDKs and any application that lets you set the OpenAI base URL
  • Three engines: OpenAI Whisper, Faster Whisper and WhisperX
  • Transcription in every language Whisper supports, and translation into English
  • Language detection with a confidence score
  • Output as plain text, JSON, WebVTT, SRT or TSV
  • Word-level timestamps, voice activity detection (VAD) and speaker diarization
  • Accepts any audio or video file FFmpeg can decode, decoded in-process with PyAV
  • Optional API key authentication
  • Unloads the model when idle to free memory
  • Interactive API documentation (Swagger UI)

Quick Start

CPU (amd64 and arm64):

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

NVIDIA GPU (amd64 and arm64, requires the NVIDIA Container Toolkit):

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

Open http://localhost:9000/docs to use the API from your browser, or send a request directly:

curl http://localhost:9000/v1/audio/transcriptions -F model=whisper-1 -F [email protected]

Or use any OpenAI SDK by setting its base URL:

from openai import OpenAI

client = OpenAI(base_url="http://localhost:9000/v1", api_key="unused")
print(client.audio.transcriptions.create(model="whisper-1", file=open("audio.mp3", "rb")).text)

Engines

Engine ASR_ENGINE Notes
OpenAI Whisper openai_whisper Reference implementation
Faster Whisper faster_whisper (default) Faster and lighter on memory; VAD and batched inference
WhisperX whisperx Word alignment and speaker diarization

Request Flow

Request flow

Configuration

The most common settings are listed below. See the configuration reference for all of them.

Variable Default Description
ASR_ENGINE faster_whisper faster_whisper, openai_whisper or whisperx
ASR_MODEL base Model name, e.g. tiny, small, large-v3, turbo
ASR_DEVICE cuda if present cuda or cpu
MODEL_IDLE_TIMEOUT 0 Seconds of inactivity before the model is unloaded
API_KEY unset Require this key in the X-API-Key header
HF_TOKEN unset Hugging Face token, required for WhisperX diarization

To avoid downloading the model on every start, mount a volume at /root/.cache:

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

Documentation

Full documentation is available at https://ahmetoner.github.io/whisper-asr-webservice.

Development

Requires Python 3.12 or 3.13 and uv.

uv sync                           # for NVIDIA GPUs: uv sync --no-group cpu --group cuda
uv run whisper-asr-webservice --host 0.0.0.0 --port 9000
uv run pytest

See the development guide for building Docker images and the documentation.

Support

Report bugs and request features on GitHub Issues. For questions and discussion, join the Discord server.

License

Released under the MIT License. Audio is decoded with PyAV, which bundles FFmpeg libraries licensed under the LGPL v3.

探索相关项目

加载中…