---
title: Real-Time Voice Interactions with the WebSocket Audio Adapter
authors: [marklysze, sternakt, davorrunje, davorinrusevljan]
tags: [Realtime API]

---

!!! warning "Deprecated"
    `RealtimeAgent` is deprecated as of v0.12 and will be removed in v0.14. It relies on deprecated realtime API endpoints. This blog post and associated notebooks will also be removed in v0.14.

![Realtime agent communication over websocket](/snippets/advanced-concepts/realtime-agent/img/websocket_communication_diagram.png)

**TL;DR:**
- **Demo implementation**: Implement a website using websockets and communicate using voice with the [**`RealtimeAgent`**](/docs/api-reference/autogen/agentchat/realtime/experimental/RealtimeAgent)
- **Introducing [**`WebSocketAudioAdapter`**](/docs/api-reference/autogen/agentchat/realtime/experimental/WebSocketAudioAdapter#websocketaudioadapter)**: Stream audio directly from your browser using [WebSockets](https://fastapi.tiangolo.com/advanced/websockets/).
- **Simplified Development**: Connect to real-time agents quickly and effortlessly with minimal setup.

# **Realtime over WebSockets**

In our [previous blog post](/docs/blog/2024/12/20/RealtimeAgent/), we introduced a way to interact with the [**`RealtimeAgent`**](/docs/api-reference/autogen/agentchat/realtime/experimental/RealtimeAgent) using [**`TwilioAudioAdapter`**](/docs/api-reference/autogen/agentchat/realtime/experimental/TwilioAudioAdapter#twilioaudioadapter). While effective, this approach required a setup-intensive process involving [Twilio](https://www.twilio.com/) integration, account configuration, number forwarding, and other complexities. Today, we're excited to introduce the[**`WebSocketAudioAdapter`**](/docs/api-reference/autogen/agentchat/realtime/experimental/WebSocketAudioAdapter#websocketaudioadapter), a streamlined approach to real-time audio streaming directly via a web browser.

This post explores the features, benefits, and implementation of the [**`WebSocketAudioAdapter`**](/docs/api-reference/autogen/agentchat/realtime/experimental/WebSocketAudioAdapter#websocketaudioadapter), showing how it transforms the way we connect with real-time agents.

## **Why We Built the [**`WebSocketAudioAdapter`**](/docs/api-reference/autogen/agentchat/realtime/experimental/WebSocketAudioAdapter#websocketaudioadapter)**
### **Challenges with Existing Solutions**
Previously introduced [**`TwilioAudioAdapter`**](/docs/api-reference/autogen/agentchat/realtime/experimental/TwilioAudioAdapter#twilioaudioadapter) provides a robust way to connect to your [**`RealtimeAgent`**](/docs/api-reference/autogen/agentchat/realtime/experimental/RealtimeAgent), but it comes with challenges:
- **Browser Limitations**: For teams building web-first applications, integrating with a telephony platform can feel redundant.
- **Complex Setup**: Configuring Twilio accounts, verifying numbers, and setting up forwarding can be time-consuming.
- **Platform Dependency**: This solution requires developers to rely on external API, which adds latency and costs.

### **Our Solution**
The [**`WebSocketAudioAdapter`**](/docs/api-reference/autogen/agentchat/realtime/experimental/WebSocketAudioAdapter#websocketaudioadapter) eliminates these challenges by allowing direct audio streaming over [WebSockets](https://fastapi.tiangolo.com/advanced/websockets/). It integrates seamlessly with modern web technologies, enabling real-time voice interactions without external telephony platforms.

import RealtimeAgent from "/snippets/advanced-concepts/realtime-agent/websocket.mdx";

<RealtimeAgent/>

## **Benefits in Action**
- **Quick Prototyping**: Spin up a real-time voice application in minutes.
- **Cost Efficiency**: Eliminate third-party telephony costs.
- **User-Friendly**: Runs in the browser, making it accessible to anyone with a microphone.

## **Conclusion**
The [**`WebSocketAudioAdapter`**](/docs/api-reference/autogen/agentchat/realtime/experimental/WebSocketAudioAdapter#websocketaudioadapter) marks a shift toward simpler, more accessible real-time audio solutions. It empowers developers to build and deploy voice applications faster and more efficiently. Whether you're creating an AI assistant, a voice-enabled app, or an experimental project, this adapter is your go-to tool for real-time audio streaming.

Try it out and bring your voice-enabled ideas to life!
