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 a complete file-processing example, follow the Python guide.
audio denotes a one-dimensional NumPy float32 array. Async fragments run inside an async function.
Model
class
Loaded model weights and model metadata. Create a model withModel.from_file(); there is no public Model() constructor. A loaded model can be shared by multiple processors. Native handles release their resources when Python releases the objects.
Example
Model.from_file()
static
str | os.PathLike | pathlib.Path
required
Path to the model file (.aicmodel). You can download models manually from artifacts.ai-coustics.io or use
Model.download() to fetch them programmatically. Accepts both string paths and pathlib.Path objects.Model: A new Model instance.
FileSystemError: The file cannot be opened.ModelInvalidErrororModelVersionUnsupportedError: Invalid or incompatible model data.
- artifacts.ai-coustics.io for available model IDs and downloads.
Model.download()
static
str
required
The model identifier (e.g.,
"quail-ms-l-16khz").str | os.PathLike | pathlib.Path
required
Directory where the model file will be stored.
str: The model file path. It remains relative whendownload_diris relative.
ModelDownloadError: Manifest access, model selection, checksum, download or filesystem failure. Inspectdetailsfor the underlying cause.
This is a blocking operation that may perform network I/O.
Model.download_async()
static
str
required
The model identifier (e.g.,
"quail-ms-l-16khz").str | os.PathLike | pathlib.Path
required
Directory where the model file will be stored.
typing.Awaitable[str]: Await it to obtain the model file path, relative whendownload_diris relative. The released.pyisaystyping.Any; the wrapper returns an awaitable resolving tostr. Background task failure can also raiseRuntimeError.
ModelDownloadError: Manifest access, model selection, checksum, download or filesystem failure. Inspectdetailsfor the underlying cause.
Model.get_id()
str: The model ID string.
Model.get_optimal_sample_rate()
ProcessorConfig to describe the actual input rate and query get_optimal_block_size(sample_rate) for that rate. See audio format for supported rates and resampling.
Returns
int: The model’s native sample rate in Hz.
Model.get_optimal_block_size()
int
required
Sample rate in Hz for which to calculate the optimal block size.
int: The optimal block size for the given sample rate.
ProcessorConfig
class
Audio configuration passed toProcessor.initialize(), Vad.initialize() and Collector.initialize().
Use ProcessorConfig.optimal() as a starting point, then adjust fields to match your audio stream.
ProcessorConfig() constructor
int
required
Input sample rate in Hz. Native initialization supports 8,000–192,000 Hz, subject to the model and configuration. This field is converted to an unsigned 32-bit integer.
int
required
Number of mono samples per call, greater than zero. This field is converted to a platform-sized unsigned integer.
bool
default:"False"
Allow calls of up to
block_size samples. With False, every call must contain exactly block_size samples.ProcessorConfig.optimal()
static
ProcessorConfig with the model’s optimal settings and any supplied overrides.
Parameters
int | None
default:"None"
Custom sample rate in Hz. If
None, uses the model’s optimal sample rate (default: None).int | None
default:"None"
Custom number of samples per processing call. If
None, uses the optimal block size for the sample rate (default: None). A non-optimal block size increases latency.bool
default:"False"
Allow calls of up to
block_size samples. With False, every call must contain exactly block_size samples.ProcessorConfig: ProcessorConfig with optimal settings for the given model.
ProcessorConfig properties
ProcessorConfig.sample_rate
int
read/write
Input sample rate in Hz. Native initialization supports 8,000–192,000 Hz, subject to the model and configuration. This field is converted to an unsigned 32-bit integer.
ProcessorConfig.block_size
int
read/write
Number of mono samples per call, greater than zero. This field is converted to a platform-sized unsigned integer. A non-optimal block size increases latency.
ProcessorConfig.variable_block_size
bool
read/write
Allows calls of up to
block_size samples, with added buffering latency. It does not change the sample rate or allow oversized blocks.OtelConfig
class
OpenTelemetry (OTel) configuration for aProcessor or Vad.
Pass to Processor, ProcessorAsync, Vad or VadAsync to control telemetry per instance. When no OtelConfig is provided, telemetry is configured according to the runtime environment (e.g. the AIC_SDK_OTEL_ENABLE environment variable).
Example
OtelConfig() constructor
enable is required; export_interval_ms is an unsigned 32-bit integer. Settings are copied into the native object at construction. Later edits to this value do not change an existing session. A session_id containing a NUL character raises InternalError when passed to a processor or detector constructor.
OpenTelemetry controls optional observability, independently of SDK authorization and usage reporting. See telemetry.
Parameters
bool
required
Whether to enable OpenTelemetry export.
str | None
default:"None"
Optional session ID. If
None, a random ID is generated.int
default:"0"
Metric export interval in ms. 0 uses the SDK default of 60,000 ms.
OtelConfig properties
OtelConfig.enable
bool
read/write
Whether to enable OpenTelemetry export. Overrides the
AIC_SDK_OTEL_ENABLE environment variable.OtelConfig.session_id
str | None
read/write
Optional session ID for telemetry. If
None, a random session ID is generated.OtelConfig.export_interval_ms
int
read/write
OpenTelemetry metric export interval in milliseconds. Set to 0 to use the SDK default of 60,000 ms.
get_sdk_version()
function
str: The library version as a string.
This is not necessarily the same as this package’s version.
get_compatible_model_version()
function
int: The compatible model version number.