Skip to main content
Crate: aic-sdk = "=0.24.0". Core SDK: 0.24.0. Source: released crate. These APIs do not require the async feature. Import types from aic_sdk; signatures below are declarations.

analyzer_pair

Creates a collector and analyzer for a Tyto analysis model and an SDK key or JWT. The collector buffers a model-defined span of audio; new audio replaces older samples. Run expensive analysis separately from collection. Invalid credentials, incompatible model types and native creation failures return AicError. The pair shares native audio state. Retained model storage keeps weights available after dropping the model handle; borrowed model bytes must still outlive the analyzer. There are no public Collector::new or Analyzer::new constructors. This function accepts no OtelConfig. Its native creation path disables optional OpenTelemetry export; SDK authorization and session reporting requirements remain separate.

Collector

A buffering handle created by analyzer_pair. Implements Drop, Send and Sync; it is not Clone. Collection uses mutable access and can run on a separate thread from the paired analyzer. Dropping it releases its native handle.

Collector::initialize

Configures the actual input rate and sample count. Use ProcessorConfig::optimal(model) as a starting point. The configuration is copied; unsupported combinations return AudioConfigUnsupported. This allocates and must run outside the audio callback.

Collector::buffer

Reads normalized mono samples without modifying the slice. Requires initialization and the configured length, or a length up to block_size with variable blocks enabled. Returns NotInitialized or AudioConfigMismatch when applicable. The call buffers audio; it does not return a score or perform the expensive analysis forward pass.

Analyzer

Analyzes audio buffered by the paired collector. Implements Drop, Send and Sync; it is not Clone. Mutable access serializes analysis and termination. The lifetime keeps borrowed model bytes alive; native handles retain model storage. Dropping the analyzer releases its handle and requests session shutdown.

Analyzer::reset

Requests reset of the shared collector state. The next collection pass clears buffered/delayed state while preserving configuration. Until then, analysis uses a zero-filled snapshot instead of the previously published audio. Use this at an application stream boundary; reset does not restore authorization or reopen a terminated session.

Analyzer::analyze_buffered

Runs the model over the latest buffered span and returns a score snapshot. Incomplete initial input is padded with silence. This is blocking computation and must run outside the audio callback. Authorization failures return ProcessingNotAllowed with no result. Repeated calls without fresh audio are not fresh independent observations.

Analyzer::terminate_session

Requests session termination. Stop analysis and treat the session as closed. Native work becomes disallowed when the lifecycle task handles the signal; with other sessions alive this can happen after the method returns. It may block for final-session shutdown. Success is not a universal remote usage acknowledgment. Create a new pair for another session.

Analyzer::update_bearer_token

Updates a JWT in a session originally created with a JWT. Returns TokenUpdateUnsupported for unsupported credential types and LicenseFormatInvalid for embedded NUL characters. Local replacement does not prove backend acceptance; keep checking analysis errors.

FileAnalyzer

Convenience analysis for a mono buffer already decoded into memory. It does not open or decode an audio file. It owns a collector/analyzer pair and borrows the Model itself for 'model; keep that model handle alive, as well as any bytes borrowed for 'a. This is stricter than using analyzer_pair directly. Its owned fields release native resources on drop. There is no public token-update, reset or session-termination method on this type. Use Analyzer directly when those lifecycle controls are required. Calls require mutable access and must be serialized.

FileAnalyzer::new

Creates the internal pair for a Tyto model. The collector is initialized by each analyze call, allowing different input rates on subsequent calls. Credential and model errors match analyzer_pair.

FileAnalyzer::analyze

Reads normalized mono samples at their actual sample_rate, leaving the slice unchanged. The native collector handles supported non-native rates; this method does not mix channels. It initializes the collector at the model’s preferred block size and analyzes independent five-second windows. step_samples is the advance between window starts. None uses 5 * sample_rate; smaller positive values overlap windows and larger values leave gaps. Rate zero or step zero returns AudioConfigUnsupported, as does an unsupported native configuration. Other initialization, buffering or analysis errors propagate as AicError without a partial result vector. Empty input and buffers up to five seconds produce one silence-padded result. Longer buffers produce only complete windows on the step grid starting at zero; partial trailing windows are omitted. Each window resets the analysis/collection state. The operation allocates and performs blocking computation; run it outside the audio callback.

AnalysisResult

An owned score snapshot. Its public fields are writable Rust values; changing them does not change the analyzer. Implements Debug, Clone and PartialEq, plus conversion from the native result struct. Values returned by the model lie between 0.0 and 1.0. They are not calibrated failure probabilities for your downstream system.

Borrowing example

This reference function accepts a loaded Tyto model, decoded mono audio and a credential from its caller. Use the Rust guide for project setup.
See Tyto analysis, errors and features and the symbol index.