Result errors. This page uses the published 0.24.0 crates. Use the Rust API reference for types, methods, features and errors. The generated crate documentation and released source are hosted on docs.rs.
Installation
Use Rust with Cargo, a native linker and libclang on a supported platform. The published SDK crate declares Rust 1.88 or later. Its build script generates C bindings with libclang; install your platform’s compiler tools before building. See the released linking guide for local-library and deployment options. Create a project:Cargo.toml with the following. download-lib downloads the matching native library during the first build; it requires network access. The explicit aic-sdk-sys pin keeps the native dependency at the documented release. hound reads and writes WAV files.
Cargo.toml
Cargo.lock in your application to preserve resolved dependency versions.
Quickstart
Prepare the key, model and input
Generate an SDK key on the developer platform. Set it in the terminal where you will run the program. Keep it out of source control and shared logs.YOUR_SDK_KEY with your key. This pins a format-7 build of quail-vf-2.2-l-16khz. Quail Voice Focus isolates the primary speaker for speech-to-text (STT) input. Downloading the model in advance does not remove SDK key authorization requirements; see authentication.
Download the noisy speech fixture and save it as input.wav in this project directory. It contains 56,080 mono PCM16 samples at 16 kHz (3.505 seconds). The fixture guide includes attribution, checksums and the aligned clean reference.
For your own recording, export mono, 16 kHz, signed 16-bit PCM WAV, at most 60 seconds long. Renaming a file does not convert it.
Save and run
Replacesrc/main.rs with:
src/main.rs
aic-rust-quickstart:
?. Rust drops the processor and model on a normal return or an error return from run, releasing native resources.
Check the result
A successful run exits with code zero, prints the native SDK version and resolved model ID, then reportsProcessed N samples at 16000 Hz; wrote enhanced.wav, where N is your input’s sample count (56080 for the supplied fixture). Open enhanced.wav in your audio editor: it should be mono, 16 kHz and the same duration as input.wav. The output is a 32-bit float WAV; the input is PCM16.
The program pads the final block, flushes the delayed tail and removes the initial processing delay, preserving the original sample count. File writes are checked; discard any incomplete file if writing fails.
Listen to both files and compare them with the same STT settings to evaluate quality.
Recover from an error
Adapt this example
Keep one processor per stream and process blocks in order. Reset its context on a discontinuity or before unrelated audio. Downmix stereo or use a processor per channel. See audio format and streams and state. The helper reads a short recording into memory. For long files and live audio, use bounded buffers and keep file I/O, model loading and session teardown outside the audio callback. For human-listening enhancement, evaluate Rook Multi Speaker.Integration behavior
Select crate features
Static linking is the default. Select one linking strategy deliberately; Cargo features are additive. See the linking guide, integration guide and examples for detailed configuration, async behavior and model embedding.
For voice activity detection (VAD) or Tyto analysis, use the dedicated types and matching models. Keep initialization, model loading and teardown outside the real-time audio callback, and follow streams and state for interruptions and concurrency.