AICFilter and returns it to your headphones. It does not require a speech-to-text (STT), language model or text-to-speech provider.
Prerequisites
- Use Python 3.11. The example targets
pipecat-ai==1.11.0andaic-sdk==3.1.0. Pipecat’saicextra requires the SDK’s 3.1 series; do not force the 3.2 SDK used by the LiveKit example into this environment. - Get an SDK key. Create one on the developer platform and keep it on the server.
- Use headphones and a microphone. Open the local client in a browser with microphone permission. Headphones prevent feedback from the loopback.
- Allow model provisioning and SDK authentication. The first connection downloads model weights. See authentication and SDK telemetry for the separate network requirements.
Installation
Create a directory and choose one setup below. Run the remaining commands there. In bash and zsh, keep package extras quoted.runner extra installs the local web client, FastAPI and Uvicorn. The webrtc extra supplies the browser transport. This example does not need PyAudio or the local extra.
On Windows, activate the environment with .venv\Scripts\Activate.ps1 in PowerShell instead of source .venv/bin/activate.
Usage
Save this complete file asbot.py:
bot.py
Running the example
Set the key in the same terminal and start the server:Check the result
Check all three signals:- Initialization: verbose logs include
ai-coustics filter started:, the selected model ID, sample rate and frames per chunk.AIC model initialization failedorai-coustics filter is not ready.means enhancement did not activate. - Audio flow:
Loopback: frames=... samples=... rate=16000 channels=1appears and its counts increase. You hear your microphone through the headphones. These counts confirm frame flow. - Continued processing: keep the connection open and check for SDK authentication or processing errors. Disconnect, reconnect and confirm initialization again.
Recover from a failure
Architecture overview
AICFilter runs inside the input transport, before downstream processors. It converts mono signed 16-bit PCM to normalized float32 SDK blocks and returns signed 16-bit PCM. It buffers partial blocks, so a call can return no audio until a complete model block is available. Stopping the filter clears the remaining partial block and terminates its processing session.
AICFilter integration
At transport startup, the filter downloads or loads the model, createsProcessorAsync for the transport sample rate and obtains a ProcessorContext for enhancement and bypass controls. It does not expose a VAD context. A process-wide model manager shares read-only enhancement weights; each filter has its own processing state.
To use a provisioned model, replace model_id and model_download_dir in bot.py with model_path=Path("path/to/model.aicmodel"). Use the path returned by Model.download; filenames can include a content identifier. SDK authentication is still required.
Monitor SDK processing
Enable OpenTelemetry for Pipecat to send SDK processing and usage metrics to your collector. The guide covers shell and.env configuration, collector endpoints, containers and receipt checks.
Standalone ai-coustics VAD
AICQuailVADAnalyzer performs independent voice activity detection (VAD). In Pipecat 1.11.0 its default model ID is vad-2.1-xxs-16khz. Enhancement models cannot be used in its place.
To test VAD with the loopback above, add these imports to bot.py:
bot, replace the pipeline = Pipeline(...) block with:
-v and reconnect. As you speak and pause, look for AICQuailVADAnalyzer initialized, then User started speaking and User stopped speaking from VADProcessor. This loopback checks speech boundaries; it runs no LLM and cannot measure agent response latency.
For an existing conversational pipeline, replace the loopback analyzer’s params argument with:
LLMUserAggregatorParams(vad_analyzer=vad_analyzer) when creating LLMContextAggregatorPair. Let that aggregator own VAD instead of also adding VADProcessor. TransportParams.vad_analyzer was removed in Pipecat 1.0.
The loopback uses
stop_secs=0.8. Pipecat 1.11.0’s conversational TurnAnalyzerUserTurnStopStrategy assumes stop_secs=0.2 in its built-in STT latency estimates. A stop delay at or above that estimate leaves no additional transcript wait time and can delay turn detection. For another delay, measure the 99th-percentile time from speech end to final transcript with your VAD/STT settings. Pass it in seconds as ttfs_p99_latency to the STT service constructor, such as DeepgramSTTService. Restart and reconnect the conversational pipeline to check timing warnings before measuring response latency. A custom estimate still produces the nondefault VAD warning; the loopback does not run these checks.VADParams: confidence is the probability threshold, and start_secs and stop_secs govern speech timing. The SDK arguments sensitivity, speech_hold_duration and minimum_speech_duration have been accepted but ignored since Pipecat 1.5.0 and are scheduled for removal in 2.0.0.
Adapt this example
Continue with the Pipecat 1.11.0 conversational example, which connects Deepgram speech-to-text (STT), an OpenAI large language model (LLM) and Cartesia text-to-speech (TTS). Keep the pinned Pipecat version from this guide and add thedeepgram, openai, cartesia and daily extras to the installation command above. This released example imports the Daily transport even when you select WebRTC, so it needs the daily extra; the WebRTC path does not need Daily credentials.
The example reads AIC_SDK_LICENSE, DEEPGRAM_API_KEY, OPENAI_API_KEY and CARTESIA_API_KEY; configure any additional credentials required by your chosen transport. These are server-side environment variables.
The example gives VAD ownership to LLMContextAggregatorPair through LLMUserAggregatorParams; do not also add the loopback’s VADProcessor. It applies enhancement before VAD, so review the original-audio and timing constraints above. It also writes conversation audio to local WAV files; review that recording behavior before using it with other people’s audio.
- Evaluate changes one at a time. Keep the input recording, STT version and VAD settings fixed when comparing models or enhancement levels. Measure VAD timing separately from loopback delay.
- Keep streams separate. Create a filter and VAD analyzer per concurrent stream. Let pipeline cancellation finish cleanup before reusing or discarding that session.
- Upgrade deliberately. Preserve your environment lock and model IDs, then rerun initialization, speech/silence/noise, disconnect and reconnect checks after changing Pipecat or SDK versions.
PipelineWorkerandWorkerRunnerreplace the deprecated task/runner aliases used in older examples.
Further reading
After checking your pipeline, evaluate audio and agent behavior, then prepare your deployment. Use troubleshooting to diagnose setup and runtime failures.Pipecat AICFilter
Read Pipecat’s filter documentation.
ai-coustics VAD
Understand VAD models and the distinction between SDK and Pipecat timing controls.