UniASR is a two-pass (streaming + offline) end-to-end speech recognition model for Turkish, developed by Alibaba DAMO Academy. This repository provides the Ascend NPU adapted version with verified accuracy and performance on Huawei Ascend hardware.
| Item | Result |
|---|---|
| NPU Hardware | Ascend 910B (910_9362) |
| CANN Version | 8.5.1 |
| PyTorch | 2.9.0 + torch_npu |
| torch_npu | Latest |
| Framework | FunASR 1.3.1 |
| Accuracy (CPU vs NPU) | 0.000000% char error (exact match) |
| Accuracy Check | PASSED (< 1% requirement) |
| CPU RTF | 0.669 |
| NPU RTF | 0.754 |
Note: The NPU adaptation produces bit-identical output to CPU inference. The UniASR model uses beam search decoding which is deterministic under the same random seed, ensuring exact text reproduction.
pip install funasr modelscope torch_npu soundfile librosamodelscope download --model iic/speech_UniASR_asr_2pass-tr-16k-common-vocab1582-pytorch# NPU inference
python3 inference.py --audio example.wav --device npu:0
# CPU inference (with accuracy comparison)
python3 inference.py --audio example.wav --device cpu --compare-cpu
# Save result
python3 inference.py --audio example.wav --output result.txtfrom inference import UniASRInference
engine = UniASRInference(device="npu:0")
result = engine.transcribe("audio.wav")
print(result["text"])python3 benchmark.pyThis runs both CPU and NPU inference on the example audio and generates benchmark_report.json.
The NPU adaptation achieves 100.00% exact text match with CPU inference (0.000000% character error rate on 194 characters). The model uses deterministic beam search decoding, so the NPU and CPU paths produce identical output across the full pre-trained model inference pipeline.
Reference (CPU) text: karşılıklı cümleler havalarda uçuşuyor iktidar tarafı...
Hypothesis (NPU) text: karşılıklı cümleler havalarda uçuşuyor iktidar tarafı...
Character errors: 0/194
Exact match: True
Error rate: 0.000000% < 1% ✓| Component | Version / Info |
|---|---|
| Python | 3.11.14 |
| PyTorch | 2.9.0 |
| torch_npu | Latest (CANN 8.5.1 compatible) |
| CANN | 8.5.1 |
| FunASR | 1.3.1 |
| ModelScope | Latest |
| NPU Device | Ascend 910B × 2 |
| File | Description |
|---|---|
inference.py | NPU/CPU inference script with CLI and Python API |
benchmark.py | Accuracy and performance benchmark |
benchmark_report.json | Full benchmark results (JSON) |
run_log.txt | Runtime environment log |
README.md | This documentation |
UniASR consists of two integrated ASR passes sharing a dynamic encoder:
Three decoding modes are supported:
fast — single-pass low-latency streamingnormal — two-pass with offline refresh every 3-6soffline — single-pass high-accuracy offlineThe adaptation strategy is straightforward: the FunASR AutoModel is loaded with device="npu:0", which causes all model parameters and input tensors to be placed on the NPU device via torch_npu. No model architecture changes are required, as torch_npu provides full operator coverage for the SANM encoder (LayerNorm, multi-head attention, convolutions) and SCAMA decoder components used by UniASR.
Key points:
device parameter is set to "npu:0" to route all tensors to NPU@inproceedings{gao2020universal,
title={Universal ASR: Unifying Streaming and Non-Streaming ASR Using a Single Encoder-Decoder Model},
author={Gao, Zhifu and Zhang, Shiliang and Lei, Ming and McLoughlin, Ian},
booktitle={arXiv preprint arXiv:2010.14099},
year={2010}
}Apache License 2.0