Voice
Create and control realtime assistant-ui voice sessions, state, controls, and helpers.
API Reference
createVoiceSession
createVoiceSessionoptions: { abortSignal?: AbortSignal; }abortSignal?: AbortSignalaborted: booleanonabort: ((this:AbortSignal,ev:Event)=>any)|nullreason: anythrowIfAborted: () => voidaddEventListener: { <K>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; }removeEventListener: { <K>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | EventListenerOptions): void; (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; }dispatchEvent: (event: Event) => booleanThe **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent(). MDN Reference
setup: (helpers: VoiceSessionHelpers) => Promise<VoiceSessionControls>
RealtimeVoiceAdapter
RealtimeVoiceAdapterconnect: (options: { abortSignal?: AbortSignal; }) => RealtimeVoiceAdapter.Session
useVoiceControls
const useVoiceControls: () => { connect: () => void; disconnect: () => void; mute: () => void; unmute: () => void; };useVoiceState
const useVoiceState: () => VoiceSessionState;useVoiceVolume
const useVoiceVolume: () => number;VoiceSessionControls
VoiceSessionControlsdisconnect: () => voidmute: () => voidunmute: () => void
VoiceSessionHelpers
VoiceSessionHelperssetStatus: (status: RealtimeVoiceAdapter.Status) => voidend: (reason: "finished" | "cancelled" | "error", error?: unknown) => voidemitTranscript: (item: RealtimeVoiceAdapter.TranscriptItem) => voidemitMode: (mode: RealtimeVoiceAdapter.Mode) => voidemitVolume: (volume: number) => voidisDisposed: () => boolean
VoiceSessionState
VoiceSessionStatestatus: RealtimeVoiceAdapter.Statustype: "starting" | "running"
isMuted: booleanmode: RealtimeVoiceAdapter.Mode