模型名称: pyannote/segmentation-3.0
模型链接: HuggingFace
模型描述: 基于 wav2vec2 的说话人分割模型,用于检测音频中的说话人切换点。模型对输入音频进行帧级分类,输出每帧属于 [无切换, 说话人切换] 的概率。
模型架构: CNN 特征提取器 + Transformer Encoder (12层) + 线性分割头
参数规模: 88,751,138 (~89M)
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| torchaudio | >= 2.1.0 | 音频 I/O |
| numpy | >= 1.24.0 | 数值计算 |
| soundfile | >= 0.12.0 | 音频文件读取 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch-npu==2.9.0.post1 torch==2.9.0 torchaudio==2.9.0
pip install numpy>=1.24.0 soundfile>=0.12.0 tqdm>=4.60.0npu-smi info
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"python3 inference.py --model-path ./models/pyannote_segmentation-3.0 --duration 5.0| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | None | 模型 checkpoint 路径 |
| --audio-path | str | None | 输入音频文件路径 |
| --duration | float | 5.0 | 合成测试音频时长(秒) |
| --threshold | float | 0.5 | 说话人切换检测阈值 |
[模型] pyannote/segmentation-3.0 (torch_npu standalone)
[设备] Ascend910_9362 (npu:0)
[输入] 5.0s @ 16kHz 合成音频
[输出] torch.Size([1, 500, 2]) - 500帧 x 2分类
[耗时] 1.7551s
[RTF] 0.3510
[状态] SUCCESS[基准测试] 4样本批量推理:
批量推理耗时: 6.4703s
单样本平均: 1.6176s Mean: 1.7343s
Std: 0.0261s
Min: 1.6923s
Max: 1.7645s
Median: 1.7434s运行命令:
python3 inference.py --duration 5.0输出:
============================================================
pyannote/segmentation-3.0 说话人分割推理
Direct torch_npu Inference on Ascend NPU
============================================================
[INFO] Found 2 NPU device(s)
[INFO] Using NPU device 0: Ascend910_9362
[INFO] Building SegmentationModel architecture...
[INFO] Model parameters: 88,751,138
[INFO] Model type: SegmentationModel
[INFO] Device: npu:0
[INFO] Creating synthetic test audio: 5.0s @ 16kHz
[INFO] Warmup run...
[W825 08:13:53.698550401 compiler_depend.ts:250] Warning: CAUTION: The operator 'aten::_transformer_encoder_layer_fwd' is not currently supported on the NPU backend and will fall back to run on the CPU.
[INFO] Warmup complete
[INFO] Inference completed in 1.7551s
[INFO] Output shape: torch.Size([1, 500, 2])
[INFO] Output dtype: torch.float32
============================================================
推理结果 (Single Inference Results)
============================================================
音频时长: 5.0s
推理耗时: 1.7551s
RTF (Real Time Factor): 0.3510
检测到的说话人切换点数量: 0
输出张量形状: torch.Size([1, 500, 2])输出:
----------------------------------------
Batch inference test (4 samples)...
----------------------------------------
Batch input shape: torch.Size([4, 80000])
Batch output shape: torch.Size([4, 500, 2])
Batch inference time: 6.4703s
Per-sample avg time: 1.6176s输出:
Performance Summary (10 runs):
Mean: 1.7343s
Std: 0.0261s
Min: 1.6923s
Max: 1.7645s
Median: 1.7434s


适配方式: 直接 torch_npu 推理(非 vLLM-Ascend)
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| RTF (Real Time Factor) | 0.3510 | 5秒音频推理耗时 1.70秒 |
| 批量推理吞吐 | 1.62s/sample | 4样本批量推理 |
| 推理稳定性 | Std=0.03s | 10次迭代标准差 |
| 输出形状 | (1, 500, 2) | 与模型规格一致 |
| NPU 设备 | Ascend910_9362 | 2卡可用 |
aten::_transformer_encoder_layer_fwd 算子当前在 NPU 后端不完全支持,attention 部分会回退到 CPU 执行。这会影响性能但不影响正确性。