import asynciofrom anam import AnamClientasync def main(): client = AnamClient( api_key="your-api-key", persona_id="your-persona-id", ) async with client.connect() as session: async def consume_video(): async for frame in session.video_frames(): img = frame.to_ndarray(format="rgb24") print(f"Video: {frame.width}x{frame.height}") async def consume_audio(): async for frame in session.audio_frames(): samples = frame.to_ndarray() print(f"Audio: {samples.size} samples") await asyncio.gather(consume_video(), consume_audio())asyncio.run(main())
This connects to the persona and prints frame metadata as it arrives. Replace the print calls with your own rendering logic.
When you save SDK video frames to a file, set the output writer or muxer to 25 fps. This is an output encoding hint; session.video_frames() yields frames as they arrive. Encoding saved output at 30 fps can make audio and video drift out of sync.
Never expose your API key in client-side code. The Python SDK is designed for server-side use. See Usage in Production for session token patterns.