Docker Whisper ASR
本服务为私聊语音输入提供本地语音转文字能力。它只绑定服务器本机 127.0.0.1:8791,由 PHP 后端 /api/chat/voiceToText 代理访问,不直接暴露公网。
启动
cd server/extend/whisper-asr
docker compose up -d --build
首次启动会下载 Whisper 模型到 Docker volume whisper_asr_models,耗时取决于网络和模型大小。
配置
常用环境变量:
| 变量 | 默认值 | 说明 |
|---|---|---|
ASR_MODEL |
small |
Whisper 模型名 |
ASR_DEVICE |
cpu |
cpu 或 cuda |
ASR_COMPUTE_TYPE |
int8 |
CPU 默认建议 int8 |
ASR_LANGUAGE |
空 | 留空自动识别,中文可设为 zh |
ASR_MAX_FILE_MB |
10 |
单文件最大大小 |
ASR_API_TOKEN |
空 | 配置后需要 Bearer Token |
如果配置 ASR_API_TOKEN,需要同步更新后台 AI 配置 whisper_asr_api_token。
验证
curl http://127.0.0.1:8791/health
curl -F "file=@sample.m4a" http://127.0.0.1:8791/v1/transcribe
接口成功时返回:
{
"text": "识别到的文字",
"language": "zh",
"language_probability": 0.9,
"duration": 3.2,
"duration_ms": 1200
}