AudioObserver

AudioObserver(*, logger: ForwardRef('Logger'| None = None)
Observer for user voice input Observer for user voice input Parameters:
NameDescription
loggerType: ForwardRef(‘Logger’) | None

Default: None

Instance Methods

initialize_session

initialize_session(self) -> None
No need to initialize session from this observer

on_close

on_close(self) -> None
Handle close of RealtimeClient.

on_event

on_event(self, event: RealtimeEvent) -> None
Observe voice input events from the Realtime.
Parameters:
NameDescription
eventThe event from the OpenAI Realtime API.

Type: RealtimeEvent

run

run(self, agent: RealtimeAgent) -> 
Run the observer with the agent.
When implementing, be sure to call self._ready_event.set() when the observer is ready to process events.
Parameters:
NameDescription
agentThe realtime agent attached to the observer.

Type: RealtimeAgent

run_loop

run_loop(self) -> None
Run the observer loop.

wait_for_ready

wait_for_ready(self) -> None
Get the event that is set when the observer is ready.