pub struct ProcessorAsync { /* private fields */ }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
impl ProcessorAsync
Sourcepub fn new(model: &Model<'static>, license_key: &str) -> Result<Self, AicError>
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.
Sourcepub fn with_otel_config(
model: &Model<'static>,
license_key: &str,
otel_config: &OtelConfig,
) -> Result<Self, AicError>
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.
Sourcepub async fn with_config(
self,
config: &ProcessorConfig,
) -> Result<Self, AicError>
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.
Sourcepub async fn initialize(&self, config: &ProcessorConfig) -> Result<(), AicError>
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.
Sourcepub async fn process_interleaved(
&self,
audio: Vec<f32>,
) -> Result<Vec<f32>, AicError>
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.
Sourcepub async fn process_planar(
&self,
audio: Vec<Vec<f32>>,
) -> Result<Vec<Vec<f32>>, AicError>
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.
Sourcepub async fn process_sequential(
&self,
audio: Vec<f32>,
) -> Result<Vec<f32>, AicError>
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.
Sourcepub async fn processor_context(&self) -> ProcessorContext
pub async fn processor_context(&self) -> ProcessorContext
Returns a ProcessorContext for real-time parameter control.
See Processor::processor_context for details.
Sourcepub async fn vad_context(&self) -> VadContext
pub async fn vad_context(&self) -> VadContext
Returns a VadContext for voice activity detection.
See Processor::vad_context for details.
Auto Trait Implementations§
impl !RefUnwindSafe for ProcessorAsync
impl !UnwindSafe for ProcessorAsync
impl Freeze for ProcessorAsync
impl Send for ProcessorAsync
impl Sync for ProcessorAsync
impl Unpin for ProcessorAsync
impl UnsafeUnpin for ProcessorAsync
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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