Skip to main content

Anam video avatar service for Pipecat

Project description

Pipecat Anam Integration

PyPI - Version

Generate real-time video avatars for your Pipecat AI agents with Anam.

Maintainer: Anam (@anam-org)

Installation

pip install pipecat-anam

Or with uv:

uv add pipecat-anam

You'll also need Pipecat with the services you use (STT, TTS, LLM, transport). For this repo's examples:

uv sync --extra dev --extra example

That installs all required Pipecat extras (deepgram, cartesia, google, daily, runner, webrtc) plus local tooling.

If you prefer pip:

pip install -e ".[dev,example]"

If you are building your own pipeline, install only the Pipecat extras you need.

Prerequisites

  • Anam API key
  • API keys for STT, TTS, and LLM (e.g., Deepgram, Cartesia, Google)
  • Daily.co API key for WebRTC transport (optional)

Usage with Pipecat Pipeline

The AnamVideoService wraps around Anam's Python SDK for a seamless integration with Pipecat to create conversational AI applications where an Anam avatar provides synchronized video and audio output while your application handles the conversation logic. The AnamVideoService iterates over the (decoded) audio and video frames from Anam and passes them to the next service in the pipeline.

enable_audio_passthrough=True bypasses Anam's orchestration layer and renders the avatar directly from TTS audio.

enable_session_replay=False disables session recording on Anam's backend.

from anam import PersonaConfig
from pipecat_anam import AnamVideoService

persona_config = PersonaConfig(
    avatar_id="your-avatar-id",
    enable_audio_passthrough=True,
)

anam = AnamVideoService(
    api_key=os.environ["ANAM_API_KEY"],
    persona_config=persona_config,
    api_base_url="https://api.anam.ai",
    api_version="v1",
)

pipeline = Pipeline([
    transport.input(),
    stt,
    context_aggregator.user(),
    llm,
    tts,
    anam,  # Video avatar (returns synchronized audio/video)
    transport.output(),
    context_aggregator.assistant(),
])

See example.py for a complete working example.

Initializing the Anam avatar session

On initialization, the AnamVideoService starts a non-blocking connection to the Anam backend. The StartFrame is propagated downstream immediately, and the AnamVideoService buffers TTS frames while the avatar backend is warming up. Only when SESSION_READY is received, the AnamVideoService will start forwarding TTS audio. If we don't wait for SESSION_READY, the audio will be dropped at the backend, as the engine conservatively drops incoming TTS to avoid accumulating audio in the buffer that can cause a latency buildup.

Up to and including v.0.0.3, the AnamVideoService blocked on StartFrame until the avatar backend was ready to receive audio. This results in higher pipeline startup latency as the other pipeline components (LLM/TTS/...) can only start and generate output after the avatar backend is available.

Video Post-Filter Example

The output transport scales the avatar resolution to the specified output resolution. This result in an amorphous scaling when the aspect ratios between output and avatar mismatch, i.e., the video is stretched or squeezed in on or both dimensions. To avoid this, you can apply a video post-processing filter to crop the avatar to the output aspect ratio.

example_video_post_filter.py adds a video post processing filter after AnamVideoService:

  • It works on OutputImageRawFrame and does not depend on Anam internals.
  • It assumes packed RGB24 bytes (format="RGB").
  • It performs a centered crop to match the configured output aspect ratio.
  • It does not scale. Pipecat output transport can still scale as needed.
  • It is a no-op when source and target aspect ratios already match.

The reusable helper lives in examples/video_post_filter.py. The same helper can be used with any Pipecat service producing OutputImageRawFrame.

Running the Example

  1. Install dependencies:
uv sync --extra dev --extra example
  1. Set up your environment:
cp env.example .env
# Edit .env with your API keys
  1. Run:
uv run python example.py -t daily

Or with the built-in WebRTC transport:

uv run python example.py -t webrtc

The bot will create a room (or use the built-in client) with a video avatar that responds to your voice.

To run the center-aspect post-filter example:

uv run python example_video_post_filter.py

or with the Daily transport:

uv run python example_video_post_filter.py -t daily

Compatibility

  • Tested with Pipecat v0.0.100+
  • Python 3.10+
  • Daily transport or built-in WebRTC transport

License

BSD-2-Clause - see LICENSE

Support

Project details


Download files

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

Source Distribution

pipecat_anam-0.0.4a2.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

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

pipecat_anam-0.0.4a2-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file pipecat_anam-0.0.4a2.tar.gz.

File metadata

  • Download URL: pipecat_anam-0.0.4a2.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pipecat_anam-0.0.4a2.tar.gz
Algorithm Hash digest
SHA256 e7304ca3710c1ff511cc3aefd349ddb08a83e3b041f9c446ad787174a2feec63
MD5 982513eb0a90f2d6b9ac291d1e59b510
BLAKE2b-256 b549ca3a5715a7f89565708a2e92bb041de9eed87b07e4ccf1fafb1ab01d06dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pipecat_anam-0.0.4a2.tar.gz:

Publisher: release-alpha.yml on anam-org/pipecat-anam

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

File details

Details for the file pipecat_anam-0.0.4a2-py3-none-any.whl.

File metadata

  • Download URL: pipecat_anam-0.0.4a2-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pipecat_anam-0.0.4a2-py3-none-any.whl
Algorithm Hash digest
SHA256 0c2a85fba6b6da30610d912e623cde21c0aaa93f56b96792948822818bd51d9f
MD5 f720555a667058fd95fd799467095e0e
BLAKE2b-256 aa88d3d7a6b38c89dbcdd994ebc379232249e432d02253e086c2b02e08d34573

See more details on using hashes here.

Provenance

The following attestation bundles were made for pipecat_anam-0.0.4a2-py3-none-any.whl:

Publisher: release-alpha.yml on anam-org/pipecat-anam

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

Supported by

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