panhg/speech_UniASR_asr_2pass-vi-16k-common-vocab1001-pytorch-offline
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

UniASR Vietnamese ASR - Ascend NPU Adaptation

ModelScope NPU Verified Accuracy Framework

Model Overview

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.

PropertyValue
Original Modeliic/speech_UniASR_asr_2pass-vi-16k-common-vocab1001-pytorch-offline
FrameworkFunASR 1.3.1 + PyTorch 2.x
LanguageVietnamese (vi)
Sample Rate16 kHz
Vocabulary~1002 char-level tokens
ArchitectureSANM Encoder + FSMN-SCAMA Decoder + CIF Predictor
Frontend80-dim fbank + LFR (lfr_m=7, lfr_n=6) → 560-dim features
NPU CompatibilityAscend 910B / 910C (CANN 8.5.1+)

NPU Adaptation Status

Check ItemStatusDetail
Model LoadingPassedFull state_dict loaded on NPU
Inference CorrectnessPassedOutput matches CPU 100%
Character Accuracy100.00%0% error rate vs CPU baseline
Performance1.59x speedupNPU sustained vs CPU
Sanity CheckPassedEnd-to-end pipeline validated

Hardware Requirements

ComponentMinimumRecommended
NPUAscend 910BAscend 910B / 910C
CANN8.5.18.5.1+
CPU Memory4 GB8 GB
NPU Memory8 GB16 GB
Disk2 GB5 GB

Environment Setup

1. Install CANN and torch-npu

# Install CANN 8.5.1 (refer to Huawei official documentation)
# Verify installation
npu-smi info

# Install torch-npu
pip install torch-npu

2. Install Dependencies

pip install funasr>=1.3.1
pip install modelscope
pip install soundfile
pip install numpy pyyaml

3. Download Model

modelscope download --model iic/speech_UniASR_asr_2pass-vi-16k-common-vocab1001-pytorch-offline \
    --local_dir ./uniASR_model

Quick Start

NPU Inference

python inference.py --device npu --audio example/asr_example.wav

CPU Inference

python inference.py --device cpu --audio example/asr_example.wav

Accuracy Comparison (CPU vs NPU)

python inference.py --device compare --audio example/asr_example.wav --output inference_log.txt

Python API

from 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")

Performance Benchmarks

Test environment: Ascend 910B, CANN 8.5.1, FunASR 1.3.1

MetricCPUNPU (first run)NPU (sustained)
Inference Time1.500s2.125s0.941s
RTF0.48080.68120.3017
Speed Ratio vs CPU1.00x0.71x1.59x

Note: The first NPU run includes kernel compilation overhead (~1.2s). Sustained runs show 1.59x speedup over CPU.

Accuracy Verification

Test audio: example/asr_example.wav (3.12s, 16kHz, Vietnamese speech)

MetricValue
CPU Resultkích thích
NPU Resultkích thích
Exact MatchTrue
Character Accuracy100.00%
Error Rate0.0000%

The NPU inference produces bit-identical output to CPU, confirming zero precision degradation.

Architecture

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 Text

File Structure

uniASR_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 output

Known Limitations

  1. Single-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.

  2. First-run overhead: NPU kernel compilation adds ~1.2s on first inference. Use --warmup flag for performance benchmarking.

  3. Only model2 (offline) decoding supported: The offline decoding mode is used. Streaming modes (fast/normal) are not implemented in this adaptation.

  4. Linux only: NPU inference requires Linux with Ascend drivers. CPU mode is available as fallback.

Citation

@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}
}

Version History

  • v1.0.0: Original PyTorch model from ModelScope
  • v1.0.1: Ascend NPU adaptation with verified accuracy and performance benchmarks