g
gcw_AVRCax4T/speech_rwkv_bat_asr-zh-cantonese-en-16k-vocab8501-pytorch-online
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

speech_rwkv_bat_asr-zh-cantonese-en-16k-vocab8501 (Ascend NPU Adaptation)

基于 RWKV BAT (Boundary Aware Transducer) 的中文/粤语/英语多语言语音识别模型, 已适配华为昇腾 Ascend 910 NPU 推理。

Model Details

FieldValue
Model Namespeech_rwkv_bat_asr-zh-cantonese-en-16k-vocab8501-pytorch-online
ArchitectureRWKV-BAT (Boundary Aware Transducer)
EncoderRWKV (18 blocks, output_size=512)
DecoderRNN-T Decoder (LSTM, hidden_size=512)
Vocabulary Size8501 tokens
Sample Rate16000 Hz
Feature80-dim fbank with LFR (m=7, n=6)
Parameters73,164,085
LanguagesMandarin Chinese, Cantonese, English
Original FrameworkPyTorch (FunASR)
SourceModelScope

NPU Adaptation Summary

ItemStatus
NPU HardwareAscend 910
CANN Version8.5.1
torch_npu Version2.9.0.post1
PyTorch Version2.9.0
FunASR Version1.3.1
Adaptation MethodModel weight loading + device migration
Model LoadingDirect state_dict loading with embed remapping
Inference PipelineFunASR RWKVEncoder + BeamSearchTransducer

Environment Setup

# Install dependencies
pip install torch==2.9.0 torch_npu==2.9.0.post1
pip install funasr modelscope soundfile librosa omegaconf
pip install torchaudio  # for feature extraction

# Verify NPU availability
npu-smi info
python -c "import torch_npu; print(torch_npu.npu.device_count())"

Quick Start

Download Model

pip install modelscope
modelscope download --model dengcunqin/speech_rwkv_bat_asr-zh-cantonese-en-16k-vocab8501-pytorch-online

Run Inference

# CPU Inference (baseline)
python inference.py --device cpu --audio <path_to_wav>

# NPU Inference
python inference.py --device npu --audio <path_to_wav>

# Accuracy Comparison (CPU vs NPU)
python inference.py --device npu --audio <path_to_wav> --compare

# Performance Benchmark (10 runs)
python inference.py --device npu --audio <path_to_wav> --benchmark

Python API

from inference import load_model, run_inference

# Load model on NPU
import torch
device = torch.device("npu:0")
model_info = load_model(device=device)

# Run inference
result = run_inference(model_info, "audio.wav")
print(f"Text: {result['text']}")
print(f"Score: {result['score']:.4f}")

Precision Validation

CPU vs NPU Output Comparison

MetricValueThresholdStatus
Text MatchExact matchN/APASS
Inference Score Diff3.91e-05< 1e-3PASS
Encoder Max Absolute Diff4.29e-06< 1e-3PASS
Encoder Mean Absolute Diff1.45e-07< 1e-3PASS
Encoder Mean Relative Diff0.0005%< 1%PASS

Test Configuration

ParameterValue
Test Audio3s synthetic speech (16kHz, mono, float32)
DecodingBeam search (beam_size=10)
PrecisionFloat32
NPU DeviceAscend 910 (npu:0)

Performance Benchmark

NPU Inference Performance

MetricNPU (Ascend 910)CPU (ARM)Speedup
Average Latency1.622s4.846s2.99x
Min Latency1.597s4.823s3.02x
Max Latency1.649s4.895s2.97x
Std Dev0.019s0.023s-
RTF (Real-Time Factor)0.5411.6152.99x

Per-Run Latency (10 runs, after 3 warmup)

RunNPUCPU
11.598s4.841s
21.638s4.836s
31.649s4.833s
41.607s4.847s
51.615s4.834s
61.629s4.828s
71.605s4.842s
81.597s4.823s
91.644s4.895s
101.634s4.886s

Test Configuration

ParameterValue
Audio Duration3.0s
Sample Rate16000 Hz
Beam Size10
Batch Size1
Test PlatformAscend 910 / CANN 8.5.1

Model Architecture

RWKV-BAT ASR Pipeline:
1. WavFrontend: 80-dim fbank extraction + LFR (7:6 stacking -> 560-dim)
2. Encoder: SimpleEmbed (Linear 560->512) + LayerNorm
   + 18x RWKV Blocks (WKLV attention + SquaredReLU FFN with gating)
   + Final LayerNorm
3. RNN-T Decoder: Embedding + LSTM(512) -> JointNetwork
4. BeamSearchTransducer: beam_size=10

Known Limitations

  1. The original model checkpoint uses a Linear embedding (embed_liner) while the current FunASR RWKVEncoder expects a CNN-based RWKVConvInput. The NPU adaptation replaces RWKVConvInput with a matching Linear layer and loads the pre-trained weights. This may differ slightly from the original training architecture.
  2. The predictor (CIF) module weights are skipped as the Transducer model does not incorporate them in the current inference pipeline.
  3. The MVN statistics file (am.mvn) is in Kaldi Nnet format, which requires Kaldi runtime for proper loading. Feature normalization is currently omitted. Full accuracy on real speech data requires proper CMVN loading.

Files

FileDescription
inference.pyNPU-adapted inference script with CPU/NPU comparison
README.mdThis deployment and evaluation report

Citation

Original model by Alibaba DAMO Academy, based on the FunASR framework and RWKV architecture.

@misc{funasr,
  author = {FunASR Team},
  title = {FunASR: A Fundamental End-to-End Speech Recognition Toolkit},
  year = {2023},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {https://github.com/alibaba-damo-academy/FunASR}
}

License

Apache License 2.0