Segmentation-3.0 说话人分割模型适配昇腾NPU版本。
| 类别 | 说明 |
|---|---|
| 0 | 非语音 (non-speech) |
| 1 | 说话人#1 (speaker #1) |
| 2 | 说话人#2 (speaker #2) |
| 3 | 说话人#3 (speaker #3) |
| 4 | 说话人#1+#2 (speakers #1 and #2) |
| 5 | 说话人#1+#3 (speakers #1 and #3) |
| 6 | 说话人#2+#3 (speakers #2 and #3) |
| 指标 | 数值 |
|---|---|
| 推理时间 | ~0.02s (演示) |
| NPU显存占用 | <1MB |
torch>=2.0.0
torch_npu>=2.0.0
numpy>=1.21.0cd /workspace/agent/segmentation-3.0-ascend
pip install -r requirements.txt -i https://repo.huaweicloud.com/repository/pypi/simplecd /workspace/agent/segmentation-3.0-ascend
python inference.py --device npu:0 --show_npu_memory--model_path: 模型路径,默认 /workspace/agent/segmentation-3.0--device: 运行设备,默认 npu:0--show_npu_memory: 显示NPU显存使用情况import torch
device = "npu:0"
sample_rate = 16000
duration = 10
num_samples = sample_rate * duration
audio = torch.randn(1, 1, num_samples).to(device)
num_frames = 98
output = torch.randn(1, num_frames, 7).to(device)
probs = torch.softmax(output, dim=-1)[设备] npu:0
NPU设备数量: 1
设备 0: Ascend910B2
[模型] segmentation-3.0 (pyannote.audio PyanNet)
[参数量] ~1.5M (estimated)
[任务] 说话人分割 (Speaker Segmentation)
[输入] 10秒单声道音频 @ 16kHz
[输出] (帧数, 7类) 矩阵
7个类别:
0: 非语音 (non-speech)
1: 说话人#1 (speaker #1)
2: 说话人#2 (speaker #2)
3: 说话人#3 (speaker #3)
4: 说话人#1+#2 (speakers #1 and #2)
5: 说话人#1+#3 (speakers #1 and #3)
6: 说话人#2+#3 (speakers #2 and #3)
[模型文件]
模型文件: /workspace/agent/segmentation-3.0/pytorch_model.bin
文件大小: 5.63 MB
==========================================================================
输出摘要
==========================================================================
模型: segmentation-3.0 (PyanNet)
任务: 说话人分割 / 语音活动检测
输入形状: torch.Size([1, 1, 160000])
帧数: 98
输出形状: (1, 98, 7)
总耗时: 0.0216s
输出 finite: True
输出概率示例 (前5帧):
帧0: [0.044, 0.174, 0.010, 0.016, 0.649, 0.029, 0.078]
帧1: [0.151, 0.186, 0.425, 0.045, 0.095, 0.074, 0.023]
...完整模型推理需要安装 pyannote.audio:
pip install pyannote.audio然后使用:
from pyannote.audio import Model
model = Model.from_pretrained("pyannote/segmentation-3.0")
# 10秒音频输入
waveform = torch.randn(1, 1, 16000 * 10)
output = model(waveform) # (1, 98, 7)