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.
Processor
class
Stateful mono audio enhancement. Use one processor per independent audio stream. Initialization and processing on the same synchronous instance must not overlap. A context can control parameters from another thread. Native resources are released when Python releases the object; explicit session termination is permanent for that instance. ExampleProcessor() constructor
initialize() before processing audio.
Parameters
str
required
SDK key or JWT for the ai-coustics SDK (generate your key at developers.ai-coustics.com).
ProcessorConfig | None
default:"None"
Optional audio processing configuration. If provided, the processor will be initialized immediately with this configuration. See
ProcessorConfig.OtelConfig | None
default:"None"
Per-instance OpenTelemetry settings. See
OtelConfig.- SDK exceptions: Invalid credentials, unsupported model types or native creation failures.
AudioConfigUnsupportedError: If the supplied config is unsupported.
Processor.initialize()
Model.get_optimal_sample_rate() and Model.get_optimal_block_size().
Parameters
ProcessorConfig
required
Audio processing configuration. See
ProcessorConfig.AudioConfigUnsupportedError: If the audio configuration is unsupported.
Processor.process()
float32 array and returns a new one-dimensional float32 array with the same number of samples. The wrapper copies the input before native processing, so the input remains unchanged, including for strided views. It releases the Python GIL during native work.
Pass exactly config.block_size samples, or 1 through config.block_size with variable_block_size=True. Values represent normalized audio, conventionally -1.0 to 1.0; the wrapper does not normalize integers or mix channels. Wrong dimensionality or dtype raises TypeError before processing.
On an SDK error, Python raises an exception and returns no processed array. Implement an explicit fallback if your application must keep delivering audio.
Raises
NotInitializedError: If the processor has not been initialized.AudioConfigMismatchError: If the block size does not match the configuration.ProcessingNotAllowedError: If processing is not authorized.
Processor.get_context()
ProcessorContext instance.
This can be used to control all parameters and other settings of the processor.
Returns
ProcessorContext: A new ProcessorContext instance.
Processor.terminate_session()
ProcessorAsync
class
Async wrapper forProcessor that offloads work to background threads.
Awaitable initialization, processing and termination use a shared background processing pool. Set AIC_NUM_THREADS before the first pool use to override its default of available CPU parallelism. AIC_NUM_RUNTIME_THREADS separately controls the async runtime and defaults to one.
The constructor is synchronous, including initialization when config is supplied. get_context() is also synchronous and can wait for in-flight work. To avoid synchronous initialization, omit config and await initialize_async(config). Calls on one instance serialize internally; await each block in stream order and bound work across streams. Do not infer an unbounded queue or cancellation guarantee from the async API.
Example
ProcessorAsync() constructor
initialize_async() before processing audio.
Parameters
str
required
SDK key or JWT for the ai-coustics SDK (generate your key at developers.ai-coustics.com).
ProcessorConfig | None
default:"None"
Optional audio processing configuration. If provided, the processor will be initialized immediately with this configuration. See
ProcessorConfig.OtelConfig | None
default:"None"
Per-instance OpenTelemetry settings. See
OtelConfig.- SDK exceptions: Invalid credentials, unsupported model types or native creation failures.
AudioConfigUnsupportedError: If the supplied config is unsupported.
ProcessorAsync.initialize_async()
async
Model.get_optimal_sample_rate() and Model.get_optimal_block_size().
Parameters
ProcessorConfig
required
Audio processing configuration. See
ProcessorConfig.AudioConfigUnsupportedError: If the audio configuration is unsupported.
ProcessorAsync.process_async()
async
float32 input on the calling thread, then returns an awaitable resolving to a new float32 array. Native processing runs in the background; input remains unchanged. The length, dtype and error rules of Processor.process() apply.
Raises
NotInitializedError: If the processor has not been initialized.AudioConfigMismatchError: If the block size does not match the configuration.ProcessingNotAllowedError: If processing is not authorized.
ProcessorAsync.get_context()
ProcessorContext for real-time parameter control.
Returns
ProcessorContext: A new ProcessorContext instance.
ProcessorAsync.terminate_session_async()
async
ProcessorContext
class
Shared control handle for processor state and parameters. There is no publicProcessorContext() constructor. Contexts from the same processor share control state. Retaining a context does not create a new processing stream or resume a terminated session.
Created via Processor.get_context().
ProcessorContext.reset()
Concurrency. The context can request a reset from another thread. Python calls still involve the interpreter; this is not a hard real-time guarantee for a Python callback.
ProcessorContext.set_parameter()
VoiceGain is a deprecated no-op: setting it emits DeprecationWarning and returns None; reading it emits the warning and returns 1.0.
Parameters
ProcessorParameter
required
Parameter to modify. See
ProcessorParameter.float
required
New parameter value. See parameter documentation for ranges.
ParameterOutOfRangeError: If the parameter value is out of range.
ProcessorContext.get_parameter()
ProcessorParameter
required
Parameter to query. See
ProcessorParameter.float: The current parameter value.
ProcessorContext.parameter()
deprecated
ProcessorContext.get_audio_delay()
Processor.process() this many samples behind its input.
It does not include VAD delay; use VadContext.get_prediction_delay() for a separate VAD.
Delay behavior.
- Before initialization: Returns the base processing delay using the model’s optimal block size at its native sample rate
- After initialization: Returns the actual delay for your specific configuration, including any additional buffering introduced by a non-optimal block size
int: The delay in samples.
After initialization, delay is expressed in samples at the configured sample rate; before initialization, use the model native rate. To convert to time units:
delay_ms = (delay_samples * 1000) / sample_rateUsing a block size different from the optimal value returned by
get_optimal_block_size() will increase the delay beyond the model’s base latency.ProcessorContext.update_bearer_token()
TokenUnsupportedError error 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.
ProcessorParameter
enum
Parameter constants for audio enhancement. Use the named constants directly. The stub presents this type as an enum; the runtime exposes PyO3 enum-like objects, so do not depend on standard-libraryenum.Enum iteration or .value behavior.
ProcessorParameter members
ProcessorParameter.Bypass
Controls whether audio processing is bypassed while preserving algorithmic delay. When enabled, the input audio passes through unmodified, but the output is still delayed by the same amount as during normal processing. The delay remains when switching between bypass and enhancement. Range: 0.0–1.0- 0.0: Enhancement active (normal processing)
- Any value greater than 0.0 up to 1.0: Bypass enabled (latency-compensated passthrough); reading the value returns 1.0
ProcessorParameter.EnhancementLevel
Tune enhancement strength for your speech-to-text (STT) engine or listening task. The exact behavior depends on the active model:- Quail models: Controls how aggressively the model suppresses noise. When used with Quail Voice Focus, it also suppresses background and competing speech.
- Rook models: Controls the mixback and therefore the intensity of the enhancement.
get_parameter() when needed.
ProcessorParameter.VoiceGain
deprecated
Retained for compatibility. Setting any value emitsDeprecationWarning and has no effect; reading returns 1.0 with the same warning.
See the Python API index, Python guide and troubleshooting.