Skip to main content

ai-coustics LiveKit plugin for Python

Audio enhancement, voice activity detection, and audio-quality analysis for LiveKit Agents, backed by the public aic-sdk package.

This package replaces livekit-plugins-ai-coustics. Do not install both packages because they provide the same livekit.plugins.ai_coustics import path.

Installation

pip uninstall livekit-plugins-ai-coustics
pip install ai-coustics-livekit-plugin
export AIC_SDK_LICENSE=...

Migrating from the official LiveKit plugin

The Python import remains livekit.plugins.ai_coustics, but the public APIs are different:

Official LiveKit plugin This package
audio_enhancement(...) Processor(model=...)
EnhancerModel.* An SDK Model loaded from a provisioned model file
ModelParameters or update_model_parameters(...) processor.get_context().set_parameter(...)
VAD() and VadSettings VAD(model=..., vad_parameters=VADParameters(...))
Auth.livekit_cloud() or Auth.ai_coustics_api(...) AIC_SDK_LICENSE or license_key=

Before:

processor = ai_coustics.audio_enhancement(
    model=ai_coustics.EnhancerModel.QUAIL_L,
)
vad = ai_coustics.VAD()

After loading the SDK models as described below:

processor = ai_coustics.Processor(model=enhancement_model)
vad = ai_coustics.VAD(model=vad_model)
frame_processor = ai_coustics.FrameProcessorChain(vad.processor, processor)

This package still uses a dedicated SDK VAD model. Like the official plugin, inference runs in the RoomIO frame-processor path and the VAD streams consume frame metadata. Provision a separate VAD model and install vad.processor as described below. LiveKit Cloud authentication is not carried over; obtain an ai-coustics SDK license before migrating.

Model provisioning

Download models during deployment or container setup:

from livekit.plugins import ai_coustics

enhancement_path = ai_coustics.Model.download("quail-vf-2.2-l-16khz", "./models")
vad_path = ai_coustics.Model.download("vad-2.1-xxs-16khz", "./models")
analysis_path = ai_coustics.Model.download("tyto-1.1-l-16khz", "./models")

Enhancement and VAD models are different model types. Make the returned paths available to your worker, then load each model once per worker process:

enhancement_model = ai_coustics.Model.from_file(enhancement_path)
vad_model = ai_coustics.Model.from_file(vad_path)
analysis_model = ai_coustics.Model.from_file(analysis_path)

Usage

Create a Processor and VAD for each agent session:

from livekit.agents import AgentSession, room_io
from livekit.plugins import ai_coustics

processor = ai_coustics.Processor(model=enhancement_model)
vad = ai_coustics.VAD(model=vad_model)
frame_processor = ai_coustics.FrameProcessorChain(vad.processor, processor)

session = AgentSession(
    vad=vad,
    # ... stt, llm, tts
)

await session.start(
    # ... agent, room
    room_options=room_io.RoomOptions(
        audio_input=room_io.AudioInputOptions(noise_cancellation=frame_processor),
    ),
)

vad.processor must be installed in the noise_cancellation path whenever the VAD is used. Put it first in the chain so it runs on original microphone audio before enhancement. All VAD streams read the resulting immutable metadata, so the SDK model runs only once per audio block.

For VAD without enhancement, use noise_cancellation=vad.processor. For enhancement without VAD, use noise_cancellation=processor.

Audio-quality analysis

Create an Analyzer, install its collector in RoomIO's audio path, and subscribe to its results:

analyzer = ai_coustics.Analyzer(
    model=analysis_model,
    analysis_interval=5.0,  # seconds; 5 is the default
)


@analyzer.on("analysis_result")
def on_analysis(event: ai_coustics.AnalysisEvent) -> None:
    print(event.result.risk_score)


await session.start(
    # ... agent, room
    room_options=room_io.RoomOptions(
        audio_input=room_io.AudioInputOptions(
            noise_cancellation=analyzer.collector,
        ),
    ),
)

The Analyzer receives audio through analyzer.collector; constructing the analyzer without installing its collector does not feed it any room audio.

Results are not logged by the plugin; log or handle them in the callback.

Combining frame processors

Use FrameProcessorChain to run any number of processors in the same RoomIO audio path. For example, this runs VAD inference and analysis on the raw input before enhancement:

frame_processor = ai_coustics.FrameProcessorChain(
    vad.processor,
    analyzer.collector,
    processor,
)

await session.start(
    # ... agent, room
    room_options=room_io.RoomOptions(
        audio_input=room_io.AudioInputOptions(
            noise_cancellation=frame_processor,
        ),
    ),
)

FrameProcessorChain runs its processors in order. Keep vad.processor first: it annotates the original frame while preserving its audio. We recommend placing analyzer.collector before processor; measuring raw input makes it easier to understand how input audio quality affects the rest of the pipeline.

This still uses LiveKit's noise_cancellation slot as a temporary integration. RoomIO owns the chain and closes the processor, collector, and analyzer together.

Configuration

Set the enhancement level through the Processor context, and configure all SDK VAD parameters on the VAD factory:

processor.get_context().set_parameter(
    ai_coustics.ProcessorParameter.EnhancementLevel,
    0.8,
)

vad.set_parameters(
    ai_coustics.VADParameters(
        sensitivity=0.5,
        speech_hold_duration=0.25,
        minimum_speech_duration=0.05,
    )
)

VAD durations are specified in seconds. See the Python SDK reference and VAD guide for parameter ranges, model support, and further details.

Set AIC_SDK_LICENSE or pass license_key= to the constructor. Create a new Processor for each concurrent room; RoomIO closes it with the input stream.

Models must be provisioned explicitly. This package does not support python -m livekit.agents download-files.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_coustics_livekit_plugin-0.1.0.tar.gz (33.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_coustics_livekit_plugin-0.1.0-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file ai_coustics_livekit_plugin-0.1.0.tar.gz.

File metadata

File hashes

Hashes for ai_coustics_livekit_plugin-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2f9a4ce819d949a8f48af223185e2015f5b43a3e7ebfe3013ffd27542b8c4180
MD5 af9533ed8415f9e63b5ea39efc53513c
BLAKE2b-256 a6f8cccff8081a86bd744fdfa8a855bb2b4afa1261a855222ad5fa63fb384242

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_coustics_livekit_plugin-0.1.0.tar.gz:

Publisher: release.yml on ai-coustics/livekit-plugins

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ai_coustics_livekit_plugin-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ai_coustics_livekit_plugin-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f3c11a4b32a20ee25aa45a341841bc6c439ed4b6b3620ee296988ba27dc1e24
MD5 d904be0851062c1842c668f08cce4b23
BLAKE2b-256 7c2d0c3ebdb11a99adbf239caaed79829173b32878734ae6da9758e109db80f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_coustics_livekit_plugin-0.1.0-py3-none-any.whl:

Publisher: release.yml on ai-coustics/livekit-plugins

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page