语音活动检测(Voice Activity Detection, VAD)模型,基于 pyannote-audio 3.1.1。 本仓库为昇腾 NPU(Ascend910 / torch-npu)适配版,提供 CLI 与 FastAPI 双模式推理。
| 字段 | 值 |
|---|---|
| 原始模型 | pyannote/voice-activity-detection |
| 任务 | 语音活动检测(VAD) |
| 框架 | PyTorch + pyannote-audio 3.1.1 |
| 推理设备 | npu:0(Ascend 910) |
| 分割子模型 | pyannote/segmentation(SincNet 架构) |
模型输出 params(在 config.yaml 中):
.cuda() / torch.cuda.* / device="cuda")一律删除,模型与输入张量统一迁移到 npu:0。try: import torch_npu; torch.npu.set_device(0),失败即抛出明确错误。set_audio_backend 且依赖 torchcodec(NPU 环境无 libnvrtc),已对 pyannote.audio 的 core/io.py 打补丁改用 soundfile 读取音频。./model_weights/pyannote/voice-activity-detection,Model.from_pretrained(checkpoint=..., hparams_file=...) 本地加载,无需 HF token。pip install -r requirements.txtpython inference.py --img test_input.wav输出示例(JSON):
{
"status": "ok",
"device": "npu:0",
"num_speech_segments": 1,
"segments": [
{"start": 1.02, "end": 2.98, "duration": 1.96, "label": "SPEECH"}
]
}uvicorn inference:app --host 0.0.0.0 --port 8000调用:
curl -F "file=@test_input.wav" http://127.0.0.1:8000/predict返回 JSON:{"status", "device", "num_speech_segments", "segments"}。
.
├── inference.py # CLI + FastAPI 双模式推理脚本
├── requirements.txt # 依赖声明
├── test_input.wav # 合成测试音频(6s,1-3s 语音段)
├── model_weights/
│ └── pyannote/voice-activity-detection/
│ ├── config.yaml # VAD pipeline 配置
│ └── segmentation/ # 分割子模型权重
└── assets/ # 适配验证截图