aic-sdk==3.2.0. Core SDK: 0.24.0. Source: Python wrapper 3.2.0.
The fragments below use these imports. Supply license_key from your approved secret source and use the loaded model and initialized objects described in each section. For complete examples, follow batch call analysis with FileAnalyzer or real-time analysis with analyzer_pair.
audio denotes a one-dimensional NumPy float32 array. Async fragments run inside an async function.
analyzer_pair()
function
Collector/Analyzer pair for non-real-time analysis.
Buffer audio in the capture path and run analysis on a separate thread. The analyzer safely reads the collector across threads. Native buffering releases the GIL, but interpreter calls and strided-array copies do not guarantee hard real-time execution.
The collector retains a span of audio determined by the analysis model. As more samples get collected, old audio is discarded.
Parameters
str
required
SDK key or JWT for the ai-coustics SDK (generate your key at developers.ai-coustics.com).
LicenseFormatInvalidError: If the license key string contains null bytes.- SDK exceptions: Invalid credentials, an unsupported model type or native creation failures.
Collector
class
Buffers audio for later analysis. The collector is designed to be placed in the audio thread, buffering audio chunks for theAnalyzer to analyze later.
Created via analyzer_pair().
Collector.initialize()
Model.get_optimal_sample_rate() and Model.get_optimal_block_size() avoids internal resampling and rebuffering.
Parameters
ProcessorConfig
required
Audio buffering configuration. See
ProcessorConfig.AudioConfigUnsupportedError: If the audio configuration is unsupported.
Collector.buffer()
float32 array of mono samples without changing it. Contiguous arrays are read directly and strided arrays are copied. Do not mutate input concurrently. Native work releases the GIL. Supply the configured fixed length or a length up to block_size when variable blocks are enabled. Wrong dtype or dimensionality raises TypeError.
Parameters
npt.NDArray[np.float32]
required
1D NumPy array of mono float32 samples to be buffered.
NotInitializedError: If the collector has not been initialized.AudioConfigMismatchError: If the buffer shape doesn’t match the configured audio settings.
Analyzer
class
Runs an analysis model over the audio buffered by aCollector.
Run analysis outside the audio thread. The analyzer safely reads audio from a collector on another thread.
Created via analyzer_pair().
Analyzer.reset()
Concurrency. Reset requests clear shared analyzer and collector state. Serialize reset with your application’s stream boundaries; Python calls are not a hard real-time guarantee.
Analyzer.analyze_buffered()
ProcessingNotAllowedError means no AnalysisResult is returned; other native failures use the SDK exception mapping.
Analyzes a fixed-length window determined by the model. If the collector has buffered less audio, the input tail is padded with silence.
Returns
AnalysisResult: An AnalysisResult.
This function is not real-time safe. Avoid calling it from audio threads.
Analyzer.terminate_session()
Analyzer.update_bearer_token()
TokenUnsupportedError is raised and the existing token stays in use.
Parameters
str
required
The new JWT to install.
TokenUnsupportedError: If either the original or new token is not a JWT.LicenseFormatInvalidError: If the token string contains null bytes.
FileAnalyzer
class
Analyzes complete mono audio buffers. FileAnalyzer is a convenience wrapper around aCollector and Analyzer pair for non-real-time analysis of audio that is already loaded in memory.
Each call to analyze() configures the collector for mono input with the model’s optimal block size. It analyzes independent five-second windows, advancing the start of each window by step_samples.
For a complete file-analysis example, follow batch call analysis with Tyto. For streaming analysis, use analyzer_pair() directly.
Example
FileAnalyzer() constructor
model. There is no file-path argument: decode the file into mono float32 samples before calling analyze(). Native resources are released when the object is released. This class has no public token-update or session-termination method; use the streaming Analyzer when those controls are needed.
The collector is not initialized until analyze() is called. This lets the same FileAnalyzer instance analyze mono buffers with different sample rates or step sizes.
Parameters
str
required
SDK key or JWT for the ai-coustics SDK (generate your key at developers.ai-coustics.com).
LicenseFormatInvalidError: If the license key string contains null bytes.- SDK exceptions: Invalid credentials, an unsupported model type or native creation failures.
FileAnalyzer.analyze()
float32 array of mono samples at the actual sample_rate. There is no channel mixing. Native collection handles supported non-native input rates. The wrapper reads contiguous input directly and copies strided input; native analysis releases the GIL. Do not mutate the input concurrently. Wrong dtype or dimensionality raises TypeError.
The analyzer evaluates five-second windows. FileAnalyzer buffers a window starting at sample 0, runs the analyzer once, resets, then repeats with a window starting step_samples later. If audio is empty, shorter than or equal to five seconds, it is padded with silence and a single result is returned. For longer signals, only complete five-second windows are analyzed after the first window.
Parameters
npt.NDArray[np.float32]
required
1D NumPy array of mono float32 samples to analyze.
int
required
Sample rate of audio in Hz.
int | None
default:"None"
Number of samples to advance between analysis results. Defaults to
5 * sample_rate samples with no overlap. Must be greater than zero. Smaller values overlap windows; larger values leave gaps.list[AnalysisResult]: A list ofAnalysisResultvalues, one per analysis window.
AudioConfigUnsupportedError: If the sample rate or step size is unsupported.
AnalysisResult
class
The result of analyzing an audio signal with anAnalyzer.
Returned results expose read-only properties; there is no public AnalysisResult() constructor. Scores are model outputs in the range 0.0–1.0, not calibrated probabilities or guarantees about a specific downstream system. For all fields except speaker_loudness, lower values indicate less problematic audio.
AnalysisResult.risk_score
float
read-only
Headline audio score.Predicts likelihood of failure of downstream models including speech-to-text, voice activity detection or turn-taking or speech-to-speech models. Lower indicates less problematic audio.Range: 0.0–1.0
AnalysisResult.speaker_reverb
float
read-only
Measure of speaker distance and reverberance. Lower indicates less problematic audio.Range: 0.0–1.0
AnalysisResult.speaker_loudness
float
read-only
Measure of speaker loudness.Range: 0.0–1.0
AnalysisResult.interfering_speech
float
read-only
Measure of interference from additional speakers present in audio. Lower indicates less problematic audio.Range: 0.0–1.0
AnalysisResult.noise
float
read-only
Measure of ambient or environmental noise. Lower indicates less problematic audio.Range: 0.0–1.0
AnalysisResult.codec_degradation
float
read-only
Measure of artifacts introduced by lossy speech codecs, e.g. from a low bitrate or a narrowband codec. Lower indicates less problematic audio.Range: 0.0–1.0Added in Python package 3.1.0.
AnalysisResult.packet_loss
float
read-only
Measure of audio dropouts or discontinuities in the stream, e.g. from packet loss, frame erasure, jitter or CPU overload. Lower indicates less problematic audio.Range: 0.0–1.0