Skip to main content

ProcessorAsync

Struct ProcessorAsync 

Source
pub struct ProcessorAsync { /* private fields */ }
Available on crate feature async only.
Expand description

A wrapper around Processor for use in async contexts.

§Threading

Processing runs on a background thread pool shared across all ProcessorAsync instances. The pool defaults to one thread per logical CPU. Override with the AIC_NUM_THREADS environment variable, which is read once on first use.

§Example

use aic_sdk::{Model, ProcessorAsync, ProcessorConfig};
#[tokio::main]
async fn main() -> Result<(), aic_sdk::AicError> {
    let license_key = std::env::var("AIC_SDK_LICENSE").unwrap();
    let model = Model::from_file("/path/to/model.aicmodel")?;
    let config = ProcessorConfig::optimal(&model).with_num_channels(2);

    let processor = ProcessorAsync::new(&model, &license_key)?.with_config(&config).await?;

    let mut audio = vec![0.0f32; config.num_channels as usize * config.num_frames];
    let audio = processor.process_interleaved(audio).await?;
    Ok(())
}

Implementations§

Source§

impl ProcessorAsync

Source

pub fn new(model: &Model<'static>, license_key: &str) -> Result<Self, AicError>

Creates a new async audio enhancement processor instance.

See Processor::new for details.

Source

pub fn with_otel_config( model: &Model<'static>, license_key: &str, otel_config: &OtelConfig, ) -> Result<Self, AicError>

Creates a new async audio enhancement processor instance with explicit OpenTelemetry configuration.

See Processor::with_otel_config for details.

Source

pub async fn with_config( self, config: &ProcessorConfig, ) -> Result<Self, AicError>

Initializes the async processor with the given configuration.

This is a convenience method that calls ProcessorAsync::initialize internally and returns self.

Source

pub async fn initialize(&self, config: &ProcessorConfig) -> Result<(), AicError>

Initializes the processor with the given configuration.

See Processor::initialize for details.

§Warning

This allocates memory internally. Do not call from latency-sensitive paths.

Source

pub async fn process_interleaved( &self, audio: Vec<f32>, ) -> Result<Vec<f32>, AicError>

Processes audio with interleaved channel data.

This method takes ownership of audio, moves it to a background processing thread, and returns the processed buffer.

See Processor::process_interleaved for details on the memory layout.

Source

pub async fn process_planar( &self, audio: Vec<Vec<f32>>, ) -> Result<Vec<Vec<f32>>, AicError>

Processes audio with separate buffers for each channel (planar layout).

This method takes ownership of audio, moves it to a background processing thread, and returns the processed channel buffers.

See Processor::process_planar for details on the memory layout.

Source

pub async fn process_sequential( &self, audio: Vec<f32>, ) -> Result<Vec<f32>, AicError>

Processes audio with sequential channel data.

This method takes ownership of audio, moves it to a background processing thread, and returns the processed buffer.

See Processor::process_sequential for details on the memory layout.

Source

pub async fn processor_context(&self) -> ProcessorContext

Returns a ProcessorContext for real-time parameter control.

See Processor::processor_context for details.

Source

pub async fn vad_context(&self) -> VadContext

Returns a VadContext for voice activity detection.

See Processor::vad_context for details.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.