Skip to main content

Crate aic_sdk

Crate aic_sdk 

Source
Expand description

Rust bindings for the ai-coustics SDK.

The SDK requires a license key. Generate one at developers.ai-coustics.com.

§Installation

cargo add aic-sdk --features download-lib

download-lib fetches the matching native library during the build. See docs::linking for the alternatives and for how the library is found at run time.

§Quick start

use aic_sdk::{include_model, ProcessorConfig, Model, Processor};

// Embed model at compile time (or use Model::from_file to load at runtime)
static MODEL: &[u8] = include_model!("path/to/model.aicmodel");

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Get your license key from the environment variable
    let license_key = std::env::var("AIC_SDK_LICENSE")?;

    // Load the embedded model (or download manually at https://artifacts.ai-coustics.io/)
    let model = Model::from_buffer(MODEL)?;

    // Get optimal configuration based on the selected model
    let config = ProcessorConfig::optimal(&model);

    // Create a processor and initialize it
    let mut processor = Processor::new(&model, &license_key)?.with_config(&config)?;

    // Process mono audio
    let mut audio_block = vec![0.0f32; config.block_size];
    processor.process(&mut audio_block)?;

    Ok(())
}

§Where to go next

docs::guide walks through the API, docs::examples has complete programs, and docs::linking covers how the native library is linked and found.

Models and their IDs are listed at artifacts.ai-coustics.io; the product documentation lives at docs.ai-coustics.com.

§License

This Rust wrapper is distributed under the Apache 2.0 license. The core C SDK is distributed under the proprietary AIC-SDK license.

NOTICE.txt in this crate lists the third-party software distributed with the SDK.

Modules§

docs
Long-form documentation.

Macros§

include_model
Embeds the bytes of model file, ensuring proper alignment.

Structs§

AnalysisResult
The result of analyzing an audio signal with an Analyzer.
Analyzer
Runs an analysis model over the audio buffered by a Collector.
Collector
Buffers audio for later analysis.
FileAnalyzer
Analyzes complete mono audio buffers.
Model
High-level wrapper for an ai-coustics model.
OtelConfig
OpenTelemetry configuration for a Processor or Vad.
Processor
High-level wrapper for the ai-coustics audio enhancement processor.
ProcessorAsyncasync
A wrapper around Processor for use in async contexts.
ProcessorConfig
Audio processing configuration passed to Processor::initialize, Vad::initialize and Collector::initialize.
ProcessorContext
Thread-safe control handle for a Processor.
Vad
High-level wrapper for the ai-coustics voice activity detector.
VadAsyncasync
A wrapper around Vad for use in async contexts.
VadContext
Thread-safe control handle for a Vad.

Enums§

AicError
Error type for AIC SDK operations.
DynamicLoadingErrorruntime-linking
Error returned when loading the AIC dynamic library at runtime fails.
ProcessorParameter
Configurable parameters for audio enhancement
VadParameter
Configurable parameters for Voice Activity Detection.

Functions§

analyzer_pair
Creates a collector/analyzer pair for non-real-time analysis.
get_compatible_model_version
Returns the model version compatible with the SDK.
get_sdk_version
Returns the version of the SDK.
is_library_loadedruntime-linking
Returns whether an AIC dynamic library has already been loaded.
load_libraryruntime-linking
Loads the AIC dynamic library from path when the runtime-linking feature is enabled.
set_sdk_id
This function is only used to identify SDKs by ai-coustics and should not be called by users of this crate.