本文档记录 ZipEnhancer 语音增强/降噪模型在昇腾 NPU (Ascend 910B3) 上的迁移适配与精度验证结果。
ZipEnhancer 是基于 Zipformer 架构的语音增强模型,通过多损失函数联合训练实现噪声抑制。模型输入 STFT 幅度谱和相位谱(noisy_mag + noisy_pha),输出增强后的幅度和相位,经 ISTFT 重建干净语音。模型仅 2M 参数,支持 16kHz 采样率。
相关获取地址:
参考文档:
| 组件 | 版本 |
|---|---|
CANN | 8.5.1 |
torch | 2.8.0 |
torch_npu | 2.8.0.post4 |
modelscope | 1.37.0 |
librosa | latest |
Ascend 910B3,单卡推理noisy_mag [B, 65, T] + noisy_pha [B, 65, T][B, 65, T] + 相位 [B, 65, T] + 复数谱conda create -n speech_zipenhancer_ans python=3.10 -y
conda activate speech_zipenhancer_ans
pip install torch==2.8.0 torch_npu==2.8.0.post4 \
-i https://mirrors.huaweicloud.com/repository/pypi/simple \
--trusted-host mirrors.huaweicloud.com
pip install modelscope librosa soundfile numpy \
sortedcontainers simplejson addict datasets pyarrow Pillow \
-i https://mirrors.huaweicloud.com/repository/pypi/simple \
--trusted-host mirrors.huaweicloud.commodelscope download --model damo/speech_zipenhancer_ans_multiloss_16k_base \
--local_dir ./speech_zipenhancer_ans_multiloss_16k_base# 需要先通过 STFT 提取幅度和相位特征
python inference.py --feature mag_pha.npz --device npufrom inference import run_inference
import numpy as np
mag = np.random.randn(1, 65, 100).astype(np.float32)
pha = np.random.randn(1, 65, 100).astype(np.float32)
# 完整的推理流水线需配合 STFT/ISTFTpython evaluate.py验证结果:
[1, 65, 100]测试条件:mag [1, 65, 100] + pha [1, 65, 100]。
| 指标 | CPU | NPU (Ascend 910B3) |
|---|---|---|
| 推理耗时 | 1676 ms | 63 ms |
| 加速比 | — | 27x |
对比 CPU (PyTorch) 与 NPU (torch_npu) 在相同 STFT 特征输入下 ZipEnhancer 模型的输出增强幅度。
| 指标 | 数值 |
|---|---|
| 输出形状 | [1, 65, 100] |
| 鲁棒平均相对误差 | 0.034% |
| 精度要求 | 平均相对误差 < 1% |
| 精度评测 | 通过 |
pipeline.model.model 获取 ZipEnhancer,forward 需同时传入 noisy_mag 和 noisy_pha 两个参数