UniASR is a two-pass end-to-end speech recognition model that unifies streaming and non-streaming ASR using a single encoder-decoder architecture. This is the Vietnamese language variant with 1001 subword units, adapted and verified for Huawei Ascend NPU inference.
| Property | Value |
|---|---|
| Original Model | iic/speech_UniASR_asr_2pass-vi-16k-common-vocab1001-pytorch-offline |
| Framework | FunASR 1.3.1 + PyTorch 2.x |
| Language | Vietnamese (vi) |
| Sample Rate | 16 kHz |
| Vocabulary | ~1002 char-level tokens |
| Architecture | SANM Encoder + FSMN-SCAMA Decoder + CIF Predictor |
| Frontend | 80-dim fbank + LFR (lfr_m=7, lfr_n=6) → 560-dim features |
| NPU Compatibility | Ascend 910B / 910C (CANN 8.5.1+) |
| Check Item | Status | Detail |
|---|---|---|
| Model Loading | Passed | Full state_dict loaded on NPU |
| Inference Correctness | Passed | Output matches CPU 100% |
| Character Accuracy | 100.00% | 0% error rate vs CPU baseline |
| Performance | 1.59x speedup | NPU sustained vs CPU |
| Sanity Check | Passed | End-to-end pipeline validated |
| Component | Minimum | Recommended |
|---|---|---|
| NPU | Ascend 910B | Ascend 910B / 910C |
| CANN | 8.5.1 | 8.5.1+ |
| CPU Memory | 4 GB | 8 GB |
| NPU Memory | 8 GB | 16 GB |
| Disk | 2 GB | 5 GB |
# Install CANN 8.5.1 (refer to Huawei official documentation)
# Verify installation
npu-smi info
# Install torch-npu
pip install torch-npupip install funasr>=1.3.1
pip install modelscope
pip install soundfile
pip install numpy pyyamlmodelscope download --model iic/speech_UniASR_asr_2pass-vi-16k-common-vocab1001-pytorch-offline \
--local_dir ./uniASR_modelpython inference.py --device npu --audio example/asr_example.wavpython inference.py --device cpu --audio example/asr_example.wavpython inference.py --device compare --audio example/asr_example.wav --output inference_log.txtfrom inference import run_single_inference
result, elapsed, num_frames, frontend = run_single_inference(
model_dir="/opt/atomgit/uniASR_model",
audio_path="example/asr_example.wav",
device="npu",
warmup=1
)
print(f"Transcription: {result}")
print(f"Inference time: {elapsed:.3f}s")Test environment: Ascend 910B, CANN 8.5.1, FunASR 1.3.1
| Metric | CPU | NPU (first run) | NPU (sustained) |
|---|---|---|---|
| Inference Time | 1.500s | 2.125s | 0.941s |
| RTF | 0.4808 | 0.6812 | 0.3017 |
| Speed Ratio vs CPU | 1.00x | 0.71x | 1.59x |
Note: The first NPU run includes kernel compilation overhead (~1.2s). Sustained runs show 1.59x speedup over CPU.
Test audio: example/asr_example.wav (3.12s, 16kHz, Vietnamese speech)
| Metric | Value |
|---|---|
| CPU Result | kích thích |
| NPU Result | kích thích |
| Exact Match | True |
| Character Accuracy | 100.00% |
| Error Rate | 0.0000% |
The NPU inference produces bit-identical output to CPU, confirming zero precision degradation.
Audio (16kHz WAV)
│
▼
WavFrontend (80-dim fbank + LFR)
│ 560-dim features
▼
SANM Encoder (SpecAugLFR + stride_conv)
│
▼
CIF PredictorV2 ──► pre_acoustic_embeds, scama_mask
│
▼
SANM Encoder2 (Big-Chunk)
│
▼
FSMN-SCAMA Decoder + Beam Search (beam_size=5)
│
▼
Token Decoding (CharTokenizer, 1002 vocab)
│
▼
Vietnamese TextuniASR_model/
├── inference.py # NPU-adapted inference script
├── README.md # This documentation
├── config.yaml # Model architecture config
├── decoding.yaml # Beam search config
├── model.pb # PyTorch state_dict (~367 MB)
├── configuration.json # ModelScope metadata
├── example/
│ └── asr_example.wav # Test audio sample
└── inference_log.txt # Accuracy comparison outputSingle-run mode: Due to CIF predictor state persistence in the UniASR architecture, each inference call creates a fresh model instance. For batch processing, instantiate the model once and call init_beam_search() before each utterance.
First-run overhead: NPU kernel compilation adds ~1.2s on first inference. Use --warmup flag for performance benchmarking.
Only model2 (offline) decoding supported: The offline decoding mode is used. Streaming modes (fast/normal) are not implemented in this adaptation.
Linux only: NPU inference requires Linux with Ascend drivers. CPU mode is available as fallback.
@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}
}