aic-sdk - Rust Bindings for ai-coustics SDK
Rust wrapper for the ai-coustics Speech Enhancement SDK.
For comprehensive documentation, visit docs.ai-coustics.com.
[!NOTE] This SDK requires a license key. Generate your key at developers.ai-coustics.io.
[!WARNING] You must use a Rust version different from
1.94.0-beta.1, which was used to build the static libraries. A solution is currently in development.
Installation
Add to your project:
Quick Start
use ;
// Embed model at compile time (or use Model::from_file to load at runtime)
static MODEL: &'static = include_model!;
Usage
SDK Information
use aic_sdk;
// Get SDK version
println!;
// Get compatible model version
println!;
Loading Models
Download models and find available IDs at artifacts.ai-coustics.io.
Load from File
use Model;
let model = from_file?;
Embed at Compile Time
use ;
static MODEL: &'static = include_model!;
let model = from_buffer?;
Download from CDN
Enable the download-model feature:
use Model;
let model_path = download?;
let model = from_file?;
Model Information
// Get model ID
let model_id = model.id;
// Get optimal sample rate for the model
let optimal_rate = model.optimal_sample_rate;
// Get optimal frame count for a specific sample rate
let optimal_frames = model.optimal_num_frames;
Configuring the Processor
use ;
// Get optimal configuration for the model
let config = optimal
.with_num_channels
.with_allow_variable_frames;
println!; // ProcessorConfig { sample_rate: 48000, num_channels: 1, num_frames: 480, allow_variable_frames: false }
// Or create from scratch
let config = ProcessorConfig ;
// Processor needs to be initialized before processing
// Option 1: Create and initialize in one step
let processor = new?.with_config?;
// Option 2: Create first, then initialize separately
let mut processor = new?;
processor.initialize?;
Processing Audio
// Interleaved processing (channels interleaved in single buffer)
// Format: [l, r, l, r, ...]
let mut audio_buffer = vec!;
processor.process_interleaved?;
// Sequential processing (channels in sequence)
// Format: [l, l, ..., r, r, ...]
let mut audio_sequential = vec!;
processor.process_sequential?;
// Planar processing (separate buffer per channel)
// Format: [[l, l, ...], [r, r, ...]]
let mut audio = vec!;
processor.process_planar?;
Processor Context
The processor context provides thread-safe access to processor parameters and state. You can create multiple contexts and move them to any thread for concurrent parameter updates.
use ProcessorParameter;
// Get processor context
let proc_ctx = processor.processor_context;
// Get output delay in samples
let delay = proc_ctx.output_delay;
// Reset processor state (clears internal buffers)
proc_ctx.reset?;
// Set enhancement parameters
proc_ctx.set_parameter?;
proc_ctx.set_parameter?;
proc_ctx.set_parameter?;
// Get parameter values
let level = proc_ctx.parameter?;
println!;
Voice Activity Detection (VAD)
The VAD context provides thread-safe access to VAD parameters and state. You can create multiple contexts and move them to any thread for concurrent parameter updates.
use VadParameter;
// Get VAD context from processor
let vad_ctx = processor.vad_context;
// Configure VAD parameters
vad_ctx.set_parameter?;
vad_ctx.set_parameter?;
vad_ctx.set_parameter?;
// Get parameter values
let sensitivity = vad_ctx.parameter?;
println!;
// Check for speech (after processing audio through the processor)
if vad_ctx.is_speech_detected
Examples
See the example files for complete working examples:
examples/basic_usage.rs- Basic usage exampleexamples/build-time-download- Download and embed models at compile-timeexamples/benchmark.rs- Run multiple processor instances concurrently until the real-time requirements are not met
Run examples with:
Documentation
- Full Documentation: docs.ai-coustics.com
- Rust API Reference: docs.rs/aic-sdk
- Available Models: artifacts.ai-coustics.io
License
This Rust wrapper is distributed under the Apache 2.0 license. The core C SDK is distributed under the proprietary AIC-SDK license.