本项目基于 pyannote/speaker-diarization-3.1 开发,提供了便捷的 HTTP API 接口。
- 🎯 基于 pyannote/speaker-diarization-3.1 的高精度说话人分离
- 🔄 异步任务处理
- 💾 Redis 任务队列和结果存储
- 🐳 Docker 支持,一键部署
docker pull baoweiwei2/speaker-diarization-http:latest
docker run -d \
--name diarization-service \
-p 9001:9001 \
-e HF_TOKEN=your_huggingface_token \
-e REDIS_HOST=your_redis_host \
-e REDIS_RESULT_EXPIRE=3600 \
-v /your/model/cache:/root/.cache \
--gpus all \
baoweiwei2/speaker-diarization-http:latest- 克隆仓库
git clone https://github.com/baoweiwei12/speaker-diarization-http.git
cd speaker-diarization-http- 运行安装脚本
chmod +x install.sh
./install.sh- 配置环境变量
创建
.env文件并设置以下变量:
HF_TOKEN=your_huggingface_token
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_RESULT_EXPIRE=3600- 启动服务
python main.py访问 /docs 路径可以查看完整的 Swagger API 文档:
http://localhost:9001/docs
curl -X POST "http://localhost:9001/diarize" \
-H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F "file=@your_audio.wav"响应示例:
{
"task_id": "550e8400-e29b-41d4-a716-446655440000"
}curl -X GET "http://localhost:9001/result/{task_id}" \
-H "accept: application/json"响应示例:
{
"status": "done",
"start_time": 1678901234,
"end_time": 1678901235,
"result": [
{
"start": 0.0,
"end": 2.5,
"speaker": "SPEAKER_00"
},
{
"start": 2.5,
"end": 5.0,
"speaker": "SPEAKER_01"
}
]
}在 .env 文件中可以修改以下配置:
HF_TOKEN: HuggingFace API TokenREDIS_HOST: Redis 服务器地址REDIS_PORT: Redis 服务器端口REDIS_RESULT_EXPIRE: 结果缓存过期时间(秒)
本项目采用 MIT 协议 - 查看 LICENSE 文件了解详情