Skip to main content

Voice classes

Import these classes from talos-fluxer/voice. Talos handles signaling and media lifecycle through a VoiceAdapter. liveKitAdapter() is a factory function, not a class; its optional browser media dependency is installed separately. See the voice support contract for LiveKit, encryption, and runtime requirements.

VoiceConnection

The constructor is private. Use VoiceConnection.join(gateway, adapter, options) with a ready gateway. See the source. Join options require guildId (a string, or null for calls) and channelId. Optional fields are selfMute, selfDeaf, signal, and timeoutMs. The default join deadline is 30 seconds. Only one join may be pending per gateway/channel. Supply initial media preferences explicitly when you need them applied by the adapter. Inherited methods: on, once, emit, removeAllListeners. Events are state, audioTrack, audioTrackRemoved, speakers (participant identity strings), error, and closed (a VoiceCloseReason). Listener failures go to the gateway’s error event. A gateway interruption, server move/leave, replacement grant, or terminal media disconnect closes this object. It does not automatically rejoin. Unsupported adapter media methods reject explicitly. The join signal stops applying after a successful join; use disconnect() to close an established connection. Given an adapter implementing VoiceAdapter:

VoiceSession

The constructor is private. Use VoiceSession.join(gateway, adapter, options) when you need automatic rejoining. See the source. It accepts the connection join options plus recovery. selfMute defaults to true. Recovery defaults are five total attempts, a one-second initial delay, a 30-second maximum delay, and a 30-second gateway readiness deadline. Set recovery.maxAttempts: 0 to disable rejoining. Inherited methods: on, once, emit, removeAllListeners. Events are state, connection (VoiceConnection), retry: { attempt, reason }, audioTrack, audioTrackRemoved, speakers, and error. Listener failures go to the gateway’s error event. Successful rejoins do not reset the total attempt budget. Server moves/leaves and manual disconnect end the session permanently. Operations while recovering reject. Publications, players, and application streams must be rebuilt for each new connection; observe connection and also use the initial getter after join.

VoicePlayer

Construct new VoicePlayer(connection, options?) with a VoiceConnection, or a compatible object exposing audio publishing and the state/closed event subscriptions. A VoiceSession itself does not expose closed; use its current connection and rebuild the player after a rejoin. See the source. Options are createAudioContext and fetch. The default context comes from the browser’s Web Audio API. source can be a string URL, URL, Blob/File, ArrayBuffer, or AudioBuffer. Items play in order. Each source is fetched and decoded in full; browser codecs, CORS, and autoplay rules apply. This player does not transcode or stream large sources incrementally. Inherited methods: on, once, emit, removeAllListeners. Events are state and error. A connection closing closes its player; transient media reconnection interrupts the active item. Player cleanup does not disconnect the voice connection.

Media interfaces

These are contracts, not constructible classes:
  • VoiceAdapter: connects a grant to a fresh VoiceTransport; can advertise E2EE support.
  • VoiceTransport: owns media controls, publications, tracks, and cleanup.
  • VoiceAudioTrack: exposes id, participantId, mediaStreamTrack, attach(), and detach().
  • VoicePublication: exposes id and idempotent stop(). The caller’s source track remains caller-owned.
  • LiveKitRoom, LiveKitAdapterOptions, and LiveKitEncryption: configure the optional LiveKit boundary.
The custom-adapter contract describes cancellation, cleanup, and encryption responsibilities.