RealtimeTtsSession

A controllable realtime text-to-speech WebSocket session.

Sessions support one events collector. Call finish for graceful completion or close to cancel immediately. After either operation, no more text may be sent.

Properties

Link copied to clipboard
abstract val events: Flow<RealtimeTtsEvent>

A buffered, single-consumer stream of events received from ElevenLabs.

Functions

Link copied to clipboard
abstract suspend fun close()

Immediately closes this session. Calling it more than once is safe.

Link copied to clipboard
abstract suspend fun finish()

Gracefully signals that no more text will be sent.

Link copied to clipboard
abstract suspend fun flush()

Forces generation of text currently buffered.

Link copied to clipboard
abstract suspend fun sendText(text: String, flush: Boolean = false)

Sends non-empty partial text. Whitespace is preserved.