WebSocketAudioAdapter

WebSocketAudioAdapter(
    websocket: WebSocket,
    *,
    logger: logging.Logger | None = None
)

Observer for the OpenAI Realtime API.

Observer for handling function calls from the OpenAI Realtime API.

Parameters:
NameDescription
websocketThe websocket connection.

Type: WebSocket
loggerThe logger for the observer.

Type: logging.Logger | None

Default: None

Instance Methods

handle_speech_started_event

handle_speech_started_event(self) -> None

Handle interruption when the caller’s speech starts.


initialize_session

initialize_session(self) -> None

Control initial session with OpenAI.


on_event

on_event(self, event: autogen.agentchat.realtime.experimental.realtime_events.RealtimeEvent) -> None

Receive events from the OpenAI Realtime API, send audio back to websocket.

Parameters:
NameDescription
eventType: autogen.agentchat.realtime.experimental.realtime_events.RealtimeEvent

run_loop

run_loop(self) -> None

Reads data from websocket and sends it to the RealtimeClient.


send_mark

send_mark(self) -> None