OpenAI Live (gpt-live-1.1 / gpt-live-1) full-duplex speech-to-speech as
one stage: InputAudio in (resampled from 16 kHz to 24 kHz by default),
OutputAudio out (24 kHz). The model listens and speaks simultaneously and
takes its own turns.
Turns from the agent come in as text sent through session.commentary.append:
a Transcription (typed by a participant, sent as [speaker] text), a
Prompt (from the app), and LLMText (Octoroom.Agent.say/3, which asks
the model to say the words verbatim).
Because OpenAI Live is full-duplex and streams append-only audio and
transcript deltas without per-turn completion markers, this stage commits
user and assistant turns after brief idle pauses (:user_idle and
:assistant_idle), pushing an AssistantMessage when an utterance settles
so presence returns to "listening". When it hears someone start speaking
while an earlier reply's audio may still be playing, it notifies
:user_speaking so the agent interrupts playback.
Tools run through OpenAI Live's Responses delegation (delegation: [model: ...]).
Any %Octoroom.Agent.Tool{} structs from the agent are declared alongside
hosted tools in delegation.responses.tools; incoming function_call items
run asynchronously via Octoroom.Agent.ToolExecutor, returning
response.item.create (function_call_output) and a single response.create
once a batch finishes. With delegation: :client, session.delegation.created
events are notified as {:delegation, delegation}.
Conversation items go to the owner (Octoroom.Agent.ConversationEvents):
the model's input and output transcripts. User items have no speaker
unless typed.
Options: :model (needed, such as "gpt-live-1.1"), :voice (default
"marin"), :api_key (default OPENAI_API_KEY), :transport (:webrtc,
the default, or :websocket), :sample_rate (24_000 default, or 16_000;
WebSocket only), :delegation (:client, [model: "...", ...], or a
delegation map), :idle_timeout_s (5..60 seconds before standby, or nil
to omit; WebRTC only), :wake_policy (:speech, [type: :speech, vad_threshold: 0.5], or a map; WebRTC only), :initial_items, and,
defaulting to the runner context's, :instructions, :initial_text,
:tools and :context. The transport starts only under a runner; for tests,
pass send: fn message -> ... end to capture what would go to OpenAI, and
feed its events with {:openai_live_socket, event}.