Skip to main content
Package: 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

For a complete collector/worker example, follow real-time analysis with Tyto. Creates a 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
Model
required
The loaded model instance. See Model.
str
required
SDK key or JWT for the ai-coustics SDK (generate your key at developers.ai-coustics.com).
Returns Raises Example

Collector

class

Buffers audio for later analysis. The collector is designed to be placed in the audio thread, buffering audio chunks for the Analyzer to analyze later. Created via analyzer_pair().

Collector.initialize()

Configures the collector for specific audio settings. This function must be called before buffering any audio. Using the sample rate and block size returned by Model.get_optimal_sample_rate() and Model.get_optimal_block_size() avoids internal resampling and rebuffering. Parameters
ProcessorConfig
required
Audio buffering configuration. See ProcessorConfig.
Raises
Do not call from audio processing threads as this allocates memory.
Example

Collector.buffer()

Buffers a one-dimensional NumPy 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.
Raises Example

Analyzer

class

Runs an analysis model over the audio buffered by a Collector. Run analysis outside the audio thread. The analyzer safely reads audio from a collector on another thread. Created via analyzer_pair().

Analyzer.reset()

Requests a reset of analyzer and collector state and buffers. The collector applies it on the next collection pass. Until then, analysis reads a zero-filled snapshot instead of the previously published audio. 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.
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.
Example

Analyzer.analyze_buffered()

Analyzes the buffered signal, releasing the GIL during native work. Calls on the same analyzer must be serialized. 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
This function is not real-time safe. Avoid calling it from audio threads.
Example

Analyzer.terminate_session()

Terminates the analyzer’s telemetry session. Stop submitting audio and treat this session as closed once you request termination. Processing becomes disallowed when the native lifecycle task handles the signal. The call can return before that handling completes when other sessions remain alive; it is not proof of remote usage acknowledgment. The session is also stopped when the object is destroyed.
This method may block and is not real-time safe.

Analyzer.update_bearer_token()

Replaces the bearer token on the analyzer. Use this when your license key is a JWT and needs to be refreshed before it expires. The replacement is used for subsequent authentication. A successful update does not prove backend acceptance or uninterrupted processing; continue handling processing errors. Both the original key and the new token must be JWTs; otherwise a TokenUnsupportedError is raised and the existing token stays in use. Parameters
str
required
The new JWT to install.
Raises Example

FileAnalyzer

class

Analyzes complete mono audio buffers. FileAnalyzer is a convenience wrapper around a Collector 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

Creates a new file analyzer for a Tyto analysis model. The wrapper retains a strong reference to 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
Model
required
The loaded model instance. See Model.
str
required
SDK key or JWT for the ai-coustics SDK (generate your key at developers.ai-coustics.com).
Raises Example

FileAnalyzer.analyze()

Analyzes a complete mono audio buffer. The input must be a one-dimensional NumPy 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.
Returns
  • list[AnalysisResult]: A list of AnalysisResult values, one per analysis window.
Raises Example

AnalysisResult

class

The result of analyzing an audio signal with an Analyzer. 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
See the Python API index, batch call analysis, real-time analysis and troubleshooting.

AnalysisResult.repr()

Returns a diagnostic string containing the object’s current fields. It is not a serialization format.