Skip to main content
Crate: aic-sdk = "=0.24.0". Core SDK: 0.24.0. Source: released crate. Signatures are declarations; import the named types from aic_sdk. See the Rust guide for a complete runnable program.

Processor

Stateful mono enhancement. Use one instance per independent stream. Mutable borrowing serializes initialization, processing and termination; a separate ProcessorContext can control state from another thread. Implements Drop, Send and Sync; it is not Clone. Native model storage is retained internally, while 'a keeps any borrowed model bytes alive. Dropping the model handle does not invalidate the processor, but its borrowed backing bytes must outlive it.

Processor::new

Creates an uninitialized processor for an enhancement or bypass model. The credential is an SDK key or JWT. Invalid credentials and incompatible model types return the corresponding AicError. Call initialize or with_config before processing.

Processor::with_otel_config

Creates an uninitialized processor with explicit OpenTelemetry settings. Settings and credential data are copied into the native session. A NUL-containing SDK key returns LicenseFormatInvalid; a NUL-containing telemetry session ID returns Internal.

Processor::with_config

Consumes the processor, calls initialization and returns it on success. On failure, the consumed processor is dropped. Use this to chain construction and initialization.

Processor::initialize

Configures the input sample rate and block size, copies the settings and initializes processing state. Invalid configurations return AudioConfigUnsupported. This allocates and must run outside the audio callback. If reinitialization fails, do not continue with assumed previous settings; successfully initialize again before processing.

Processor::process

Enhances normalized mono samples in place. Fixed mode requires exactly block_size samples; variable mode accepts slices up to that size. Returns NotInitialized, AudioConfigMismatch or ProcessingNotAllowed when applicable. The returned Result must be checked even when construction succeeded. The native processor may write delay-preserving fallback samples when processing is disallowed; other errors are not a universal unchanged-buffer guarantee. Handle errors according to your application’s continuity policy.

Processor::context

Creates a shared control handle. Multiple contexts refer to the same control state, not separate audio streams. Context creation asserts native success rather than returning a Result; an internal failure can panic.

Processor::terminate_session

Requests termination of the telemetry and authorization session. Stop submitting work before termination. A successful return is not an acknowledgment that a remote service has received all usage. The object cannot start a new session; create a new processor to resume. This operation may block and is unsuitable for the audio callback. Native work becomes disallowed when the lifecycle task handles the signal; with other sessions alive that can occur after return.

ProcessorContext

Create with Processor::context or await ProcessorAsync::context. There is no public constructor. Implements Drop, Send and Sync. Contexts share native control state and can be used while another thread processes audio. Dropping a context releases that handle; it does not destroy its processor. Keeping a context does not produce audio after its processor is gone.

ProcessorContext::set_parameter

Sets a parameter using the bounds below. Values outside the accepted range, including NaN, return ParameterOutOfRange.

ProcessorContext::parameter

Reads the current parameter value. Read the active model’s enhancement level rather than assuming a universal model default.

ProcessorContext::audio_delay

Returns algorithmic and internal buffering delay in samples at the configured input rate, or native rate before initialization. It excludes CPU execution time, scheduling, transport and application queues. Convert using 1000.0 * delay as f64 / sample_rate as f64. The native query is asserted and can panic on internal failure.

ProcessorContext::reset

Requests a reset. The processing path clears its state and buffers on its next processing call, retaining audio configuration. Reset does not reopen a terminated session.

ProcessorContext::update_bearer_token

Replaces a JWT in a session originally created with a JWT. Otherwise returns TokenUpdateUnsupported; an embedded NUL returns LicenseFormatInvalid. A rejected replacement is not installed. Successful local replacement does not prove backend acceptance; continue handling processing errors.

ProcessorParameter

Parameter selector. Both variants accept values from 0.0 through 1.0. Implements Debug, Clone, Copy, PartialEq, Eq and Hash, plus conversion to the matching native parameter type. There is no Rust VoiceGain variant in this release.

ProcessorParameter::Bypass

Zero enables enhancement; any positive accepted value enables delay-preserving bypass. Readback is 0.0 or 1.0. The initial bypass value is 0.0.

ProcessorParameter::EnhancementLevel

Controls enhancement strength. Quail models adjust suppression, including competing speech for Quail Voice Focus. Rook models adjust mixback for human listening. Initial strength can be model-specific; read parameter for the active value.

ProcessorAsync

Requires feature: async. Owns a synchronized processor backed by a shared worker pool. Constructors are synchronous. Methods marked async serialize access to this instance through a mutex and run expensive processing work on the pool. Await blocks in stream order and bound pending work; separate instances serve independent streams. AIC_NUM_THREADS, read when the global pool is first created, selects a positive thread count; the default is available CPU parallelism. This type requires Model<'static>, from file loading or static embedded data. It implements Send and Sync through its fields, but not Clone; use Arc to share it. No cancellation or unbounded queue guarantee is implied.

ProcessorAsync::new

Synchronously creates an uninitialized enhancement processor. Construction errors match Processor::new.

ProcessorAsync::with_otel_config

Synchronously creates an uninitialized processor with explicit telemetry settings; errors match the synchronous constructor.

ProcessorAsync::with_config

Consumes the async processor, awaits initialization and returns it. A failed initialization drops the consumed instance.

ProcessorAsync::initialize

Copies the configuration, waits for exclusive access and initializes on the processing pool. Unsupported configurations return AudioConfigUnsupported.

ProcessorAsync::process

Takes ownership of the audio vector, processes it in place on the background pool and returns the vector on success. Input size and sample rules match Processor::process. On error the vector is dropped and is not returned, including when the native processor wrote fallback data.

ProcessorAsync::terminate_session

Waits for exclusive access and requests termination on the background pool. Stop submitting audio first; create a new object for another session. Await the method, but do not treat completion as proof that native signal handling or remote usage acknowledgment has finished when other sessions remain alive.

ProcessorAsync::context

Waits for the mutex and returns a control handle. This method is async in Rust, unlike the Python wrapper’s get_context. Internal native context creation failure can panic. See the model and configuration reference, errors and features and symbol index.

Process one block

This function receives an initialized processor and a normalized mono block from the caller. Errors propagate to the application:
With the async feature, ownership of the vector passes to the operation: