本项目将 pyannote/voice-activity-detection 适配到华为昇腾 Ascend 910B (NPU),基于 pyannote.audio segmentation 模型(PyanNet)在 npu:0 上实现端到端语音活动检测。
pyannote/voice-activity-detection (HuggingFace, gated)pyannote/segmentation-3.0 (PyanNet: SincNet + BiLSTM + 帧级分类头, 7通道 powerset)working/model_dir 包含 config.yaml / pipeline.json (VAD阈值) 与 pytorch_model.bin (5.7 MB)onset=0.8104, offset=0.4806, min_duration_on=0.0553, min_duration_off=0.0979npu:0npu-smi info 可见 NPU 3 (Phy 6/7)Model.from_pretrained(model_dir, strict=False) 本地加载,不走 HF 在线下载Inference with pre_aggregation_hook=lambda scores: np.max(scores, axis=-1) 聚合为语音概率, Binarize 阈值化得到时间戳model.to(npu:0), waveform.to(npu:0), 前后 torch.npu.synchronize() 同步计时pyannote/audio/sample/sample.wav (30 s, 16kHz mono, 含语音与静音)# 单文件推理 (NPU)
source /usr/local/Ascend/cann-8.5.1/bin/setenv.bash
python inference.py --model_dir /path/to/model_dir --audio /path/to/audio.wav --device npu:0 --output_json result.json
# CPU 对比
python inference.py --model_dir /path/to/model_dir --audio audio.wav --device cpu --output_json cpu.json
# 默认使用 pyannote 样例音频
python inference.py --device npu:0assets/agent_workflow.png - 适配流程assets/npu_device_call.png - NPU 设备调用证明assets/model_result.png - 模型结果与一致性验证MIT, 遵循原始 pyannote.audio 许可。权重需在 HF 接受 gated 条件后下载。
#NPU