Advanced installation
This page is for users who want to control how the Rust crate finds and links
its native sherpa-onnx libraries.
Most users do not need anything here. The default behavior is:
Build normally.
Let the build script download the matching native libraries automatically.
Run your Rust program or one of the examples.
Use your own sherpa-onnx libraries
If you already have sherpa-onnx libraries on disk, set
SHERPA_ONNX_LIB_DIR to the lib directory before building:
export SHERPA_ONNX_LIB_DIR=/path/to/sherpa-onnx/lib
Examples:
/path/to/sherpa-onnx/build/install/lib /path/to/sherpa-onnx-v1.12.32-linux-x64-static-lib/lib
If SHERPA_ONNX_LIB_DIR is set, the build script uses that directory and
does not auto-download another archive.
Automatic download behavior
If SHERPA_ONNX_LIB_DIR is not set, sherpa-onnx-sys downloads a matching
prebuilt -lib archive from GitHub releases and uses its lib directory
automatically.
Default mode uses the crate’s default feature set, which means static
linking. If you enable the shared feature, shared archives are downloaded
instead.
Enable microphone examples
In rust-api-examples, microphone support is controlled by the mic
feature:
cd sherpa-onnx/rust-api-examples
cargo run --features mic --example streaming_zipformer_microphone -- --help
If you want both microphone support and shared libraries:
cargo run --no-default-features --features "shared,mic" \
--example streaming_zipformer_microphone -- --help