sherpa-onnx Core

raw JSON →
1.12.40 verified Mon Apr 27 auth: no python

Core shared libraries for sherpa-onnx, a cross-platform speech recognition and text-to-speech toolkit. Version 1.12.40 provides the underlying ONNX Runtime-based engines for ASR, VAD, and TTS, with package updates for various platforms. Release cadence is approximately semi-monthly.

pip install sherpa-onnx-core
error ImportError: cannot import name 'OfflineRecognizer' from 'sherpa_onnx'
cause The 'sherpa-onnx-core' package does not include the Python bindings; only the C libraries.
fix
Install 'sherpa-onnx' (pip install sherpa-onnx) which provides the Python API.
error ModuleNotFoundError: No module named 'sherpa_onnx'
cause Neither 'sherpa-onnx' nor 'sherpa-onnx-core' is installed.
fix
Run 'pip install sherpa-onnx'.
error RuntimeError: Model file not found: /path/to/encoder.onnx
cause The model path is incorrect or the model was not downloaded.
fix
Download the model files from the official model zoo and provide absolute paths.
gotcha The 'sherpa-onnx-core' package only contains shared libraries; the Python API is provided by 'sherpa-onnx'. Installing 'sherpa-onnx-core' alone will not give you importable Python modules.
fix Install 'sherpa-onnx' instead: pip install sherpa-onnx
breaking Model file formats may change between major releases. Models downloaded for version 1.9 may not work with 1.12.
fix Always download the latest model files for your sherpa-onnx version.
deprecated The 'sherpa_onnx.OfflineRecognizer' constructor signature changed in v1.10; 'from_models' is now the preferred factory method.
fix Use 'OfflineRecognizer.from_models(...)' instead of 'OfflineRecognizer(...)'.

Basic offline ASR using pre-downloaded ONNX models.

import sherpa_onnx

recognizer = sherpa_onnx.OfflineRecognizer.from_models(
    encoder="path/to/encoder.onnx",
    decoder="path/to/decoder.onnx",
    tokens="path/to/tokens.txt",
)
wave = sherpa_onnx.read_wave("test.wav")
result = recognizer.decode(wave)
print(result.text)