pub struct Analyzer<'a> { /* private fields */ }Expand description
Runs an analysis model over the audio buffered by a Collector.
The analyzer is designed to be run in a non-audio thread. Analysis models are computationally expensive and cannot run in the audio thread. The analyzer has access to the audio buffered by the collector, and it can access it safely across threads.
Implementations§
Source§impl<'a> Analyzer<'a>
impl<'a> Analyzer<'a>
Sourcepub fn reset(&self) -> Result<(), AicError>
pub fn reset(&self) -> Result<(), AicError>
Clears all internal state and buffers.
Call this when the audio stream is interrupted or when seeking to prevent mispredictions from previous audio content.
This operates on both the analyzer and its collector.
The Collector stays initialized to the configured settings.
§Returns
Returns Ok(()) on success or an AicError if the reset fails.
§Real-time safety
Real-time safe. Can be called from audio processing threads.
§Example
analyzer.reset()?;Sourcepub fn analyze_buffered(&mut self) -> Result<AnalysisResult, AicError>
pub fn analyze_buffered(&mut self) -> Result<AnalysisResult, AicError>
Analyze the buffered signal.
The analyzer runs a forward-pass of the analysis model with a fixed length of audio, determined by the model.
If this function is called before the collector has buffered that length of audio, the analyzer will run the analysis with silence (zeros) in the tail of the input.
§Note
When buffering, all channels are mixed down to mono. To analyze channels independently, create separate analyzer pairs.
§Returns
Returns an AnalysisResult if successful, otherwise an AicError.
§Real-time safety
This function is not real-time safe. Avoid calling it from audio threads.
Sourcepub fn update_bearer_token(&self, token: &str) -> Result<(), AicError>
pub fn update_bearer_token(&self, token: &str) -> Result<(), AicError>
Replaces the bearer token on the analyzer.
Use this when your license key is a JWT and needs to be refreshed before it expires. Audio processing continues uninterrupted, the context handle stays valid, and the new token is used for all subsequent authentication against the ai-coustics backend.
In-place updates are only supported when both the originally configured key and the
new token are JWTs. If either side is not, the call returns
AicError::TokenUpdateUnsupported and the existing token stays in use.
§Arguments
token- The new JWT to install.
§Returns
Returns Ok(()) on success or an AicError if the update fails.
§Real-time safety
This function is not real-time safe. It locks a mutex and allocates memory. Avoid calling it from audio threads.
§Example
let renewed_jwt = String::from("<JWT_BEARER_TOKEN>");
analyzer.update_bearer_token(&renewed_jwt)?;Trait Implementations§
impl<'a> Send for Analyzer<'a>
impl<'a> Sync for Analyzer<'a>
Auto Trait Implementations§
impl<'a> Freeze for Analyzer<'a>
impl<'a> RefUnwindSafe for Analyzer<'a>
impl<'a> Unpin for Analyzer<'a>
impl<'a> UnsafeUnpin for Analyzer<'a>
impl<'a> UnwindSafe for Analyzer<'a>
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