This repository contains the Ascend NPU-adapted version of gomodels/sherpa, which bundles two state-of-the-art speech models:
| Model | Task | Architecture | Backend |
|---|---|---|---|
| SenseVoice | Speech Recognition (ASR) | CTC Transformer | ONNX Runtime + torch_npu |
| Matcha-TTS | Text-to-Speech (TTS) | Flow Matching + Vocos | ONNX Runtime + torch_npu |
The NPU adaptation employs a hybrid acceleration architecture:
| Task | Metric | Result | Threshold | Status |
|---|---|---|---|---|
| ASR (SenseVoice) | Text Match | 100% match | Exact match | PASS |
| TTS (Matcha-TTS) | NRMSE | 0.0000% | < 1% | PASS |
| TTS (Matcha-TTS) | Correlation | 1.0000 | > 0.99 | PASS |
| Task | Device | Avg Time (s) | RTF | Speed (x real-time) |
|---|---|---|---|---|
| ASR (5.6s audio) | CPU | 0.288 | 0.052 | 19.4x |
| ASR (5.6s audio) | NPU | 0.275 | 0.049 | 20.3x |
| TTS (4.1s output) | CPU | 0.260 | 0.064 | 15.7x |
| TTS (4.1s output) | NPU | 0.274 | 0.067 | 14.9x |
# Install dependencies
pip install sherpa-onnx onnxruntime onnx soundfile numpy librosa
# Ascend NPU dependencies (pre-installed on Ascend servers)
# torch_npu, CANN toolkitpip install modelscope
modelscope download --model gomodels/sherpaSpeech Recognition (ASR):
# CPU mode
python inference.py --task asr --input audio.wav --device cpu
# NPU mode
python inference.py --task asr --input audio.wav --device npu
# Test with included sample
python inference.py --task asr \
--input ~/.cache/modelscope/hub/models/gomodels/sherpa/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/test_wavs/zh.wav \
--device npuText-to-Speech (TTS):
# CPU mode
python inference.py --task tts --input "你好世界" --output output.wav --device cpu
# NPU mode
python inference.py --task tts --input "你好世界" --output output.wav --device npuAccuracy Validation:
python inference.py --task validatePerformance Benchmark:
# CPU + NPU comparison
python benchmark.py --task all --runs 5 --device bothsherpa-npu/
├── inference.py # Main inference script (ASR + TTS, CPU + NPU)
├── npu_tts.py # NPU-accelerated TTS with PyTorch weights
├── benchmark.py # Performance benchmarking script
├── README.md # This documentation
├── requirements.txt # Python dependencies
└── results/ # Evaluation results
├── accuracy_validation.json
└── benchmark.jsonApache License 2.0