g
gcw_AVRCax4T/whisper-tiny-onnx
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Whisper Tiny ONNX - Ascend NPU Adaptation

Model Introduction

Whisper Tiny is OpenAI's lightweight speech recognition model (37.8M parameters), adapted from the manyeyes/whisper-tiny-onnx ModelScope repository. This repository provides NPU-adapted inference scripts and evaluation results for running Whisper Tiny on Huawei Ascend 910 NPUs via torch_npu.

Model Architecture

ComponentConfiguration
Encoder Layers4
Decoder Layers4
Hidden Dimension384
Attention Heads6
Vocabulary Size51,865
Mel Bands80
Max Audio Context1,500 (30s @ 16kHz)
Max Text Context448
Parameters37.8M (144 MB FP32)
Languages99 (multilingual)

Source Model

  • ModelScope: manyeyes/whisper-tiny-onnx
  • Original: OpenAI Whisper Tiny
  • Task: Automatic Speech Recognition (ASR)

Quick Start

Environment Requirements

  • Hardware: Huawei Ascend 910 NPU (Atlas 800 A2/A3)
  • CANN: 8.5.1+
  • Python: 3.11+
  • PyTorch: 2.9.0+
  • torch_npu: 2.9.0+

Installation

# Install ModelScope
pip install modelscope

# Download model
modelscope download --model manyeyes/whisper-tiny-onnx --local_dir ./model

# Install dependencies
pip install torchaudio soundfile scipy librosa

Inference

# Generate test audio and run CPU inference (baseline)
python inference.py --audio /tmp/test_audio.wav --generate-audio --device cpu

# NPU inference
python inference.py --audio /tmp/test_audio.wav --device npu:0

# Accuracy comparison (CPU vs NPU)
python inference.py --audio /tmp/test_audio.wav --device npu:0 --compare

# Performance benchmark with 20 iterations
python inference.py --audio /tmp/test_audio.wav --device npu:0 --benchmark 20

Python API

from inference import load_model, load_audio, compute_mel, greedy_decode, decode_tokens

# Load model on NPU
model = load_model("model/tiny.pt", device="npu:0")

# Load and preprocess audio
audio = load_audio("audio.wav")
mel = compute_mel(audio, device="npu:0")

# Run inference
tokens, enc_time = greedy_decode(model, mel, language="en", device="npu:0")
text = decode_tokens(tokens)
print(text)

Evaluation Results

Test Environment

ItemSpecification
NPUAscend 910 (9362) x2
CANN8.5.1
PyTorch2.9.0+cpu
torch_npu2.9.0.post1+gitee7ba04
PrecisionFP32
Test Date2026-05-17

Accuracy (CPU vs NPU)

Evaluation metric: Robust Relative Error — for values where CPU reference > 1e-6, compute |NPU - CPU| / |CPU| and average across all elements. Quality gate: < 1%.

Test CaseInput ShapeOutput ShapeMax Abs ErrorRobust Rel ErrorStatus
5s audio[1, 80, 500][1, 250, 384]0.0095420.4754%PASS
10s audio[1, 80, 1000][1, 500, 384]0.0096860.6799%PASS
20s audio[1, 80, 2000][1, 1000, 384]0.0095940.5687%PASS
30s audio[1, 80, 3000][1, 1500, 384]0.0142660.7118%PASS

Accuracy Verdict: ALL PASSED

  • Quality Gate (< 1%): PASSED
  • Worst-case Max Abs Error: 0.014266
  • Worst-case Robust Rel Error: 0.7118%
  • Text-level Match: CPU and NPU produce 100% identical transcription output

End-to-End Inference Accuracy

MetricValue
CPU-NPU Text MatchTrue (100%)
Feature Max Abs Error0.001993
Feature Mean Abs Error0.000196
Feature Relative Error0.0200%

Performance Benchmark

Encoder Latency

Audio DurationCPU Time (ms)NPU Time (ms)CPU p99 (ms)NPU p99 (ms)SpeedupNPU RTF
5s86.282.2587.042.3238.3x0.00045
10s185.192.24197.992.2982.6x0.00022
20s833.952.173644.532.22384.1x0.00011
30s899.052.90912.052.93309.7x0.00010

End-to-End Latency (30s audio, 20-token decode)

ComponentLatency (ms)
Encoder3.37
Decoder (20 tokens)49.68
Per-token decoder2.48
Total E2E53.05
Encoder Throughput890,007 mel-frames/s

Key Findings

  1. Accuracy: CPU-NPU feature-level robust relative error is 0.71% (worst case), passing the 1% quality gate. Text-level outputs are 100% identical between CPU and NPU. Feature-level relative error is only 0.02% on real audio inference.

  2. Performance: NPU achieves 38x–384x speedup over CPU for encoder inference. Real-Time Factor (RTF) is well below 0.001, enabling real-time streaming ASR with large headroom.

  3. Memory: Model occupies approximately 144 MB in FP32, fitting comfortably within the Ascend 910's 64 GB HBM.

  4. Stability: NPU inference time remains nearly constant across all input durations (2.2–2.9 ms), while CPU time scales linearly with audio length.

Deliverables

FileDescription
inference.pyNPU-adapted inference script with CPU/NPU backends, accuracy comparison, and benchmarking
eval_benchmark.pyComprehensive accuracy and performance evaluation suite
eval_results.jsonStructured evaluation results (accuracy + performance)
run_log.logFull evaluation run log
README.mdDeployment documentation and evaluation report
model/Downloaded model files (tiny.pt, ONNX encoders/decoders)

File Structure

whisper-tiny-onnx-npu/
├── README.md              # This document
├── inference.py           # NPU inference script
├── eval_benchmark.py      # Evaluation suite
├── eval_results.json      # Evaluation results (structured)
├── run_log.log            # Full run log
└── model/                 # Model files
    ├── tiny.pt            # PyTorch checkpoint
    ├── encoder.onnx       # ONNX encoder (FP32)
    ├── encoder.int8.onnx  # ONNX encoder (INT8)
    ├── decoder.onnx       # ONNX decoder (FP32)
    ├── decoder.int8.onnx  # ONNX decoder (INT8)
    ├── conf.json          # Model config
    └── configuration.json # Additional config

Citation

@misc{whisper-tiny-onnx-npu,
  title={Whisper Tiny ONNX - Ascend NPU Adaptation},
  author={Model Agent},
  year={2026},
  note={Adapted from manyeyes/whisper-tiny-onnx on ModelScope. Evaluated on Huawei Ascend 910 NPU.}
}

Hardware Tags

#NPU #Hardware/NPU #Ascend #Ascend910 #CANN #torch_npu #Whisper #ASR #ONNX #pretrained