Skip to content

VoiceSession

A live voice session.

readonly sessionId: string

The session id.


readonly state: SessionState

The current state. listening once connect() has resolved.


readonly transport: "webrtc" | "websocket"

The transport in use: webrtc, or websocket after the fallback.

end(): Promise<void>

Ends the session and releases the microphone.

Promise<void>


interrupt(): void

Stops the reply now, as if the person had started speaking.

void


levels(): object

Loudness, 0..1, for meters.

object

input: number

output: number


mute(muted): void

Mutes or unmutes the microphone.

boolean

void


on<K>(name, fn): () => void

Subscribes; the returned function unsubscribes. A new state listener first gets the current state, once, in a microtask after on() returns; then every change. Events that arrived while connect() was running are delivered in a task after it resolves, so listeners attached right after await connect() miss none of them.

K extends keyof SessionEvents

K

(e) => void

() => void


resumeAudio(): void

After a non-fatal audio_unavailable (the browser refused to play the voice): call it synchronously in a click or tap handler. It resumes the audio and retries playing the voice inside that gesture; the conversation goes on. If the browser still refuses, audio_unavailable is reported again. Does nothing after ended.

void


sendText(text): void

Sends a typed turn (at most 2,000 characters; longer throws RangeError).

string

void