RealtimeTranslationConnection class

A connection to a Realtime translation session.

Translation sessions stream source audio in and translated audio plus transcript deltas out continuously. They use a different event surface from regular Realtime sessions — see RealtimeTranslationServerEvent for the event types you'll receive on events.

Properties

events Stream<RealtimeTranslationServerEvent>
Stream of translation server events.
no setter
hashCode int
The hash code for this object.
no setterinherited
isClosed bool
Whether the connection is closed.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

appendAudio(String audioBase64, {String? eventId}) → void
Appends base64-encoded 24 kHz PCM16 mono audio bytes to the input buffer. The translation engine consumes 200 ms frames.
appendAudioBytes(List<int> audioBytes, {String? eventId}) → void
Convenience over appendAudio: base64-encodes the raw audio bytes for you. The translation flow expects 24 kHz PCM16 mono little-endian audio in 200 ms frames. This helper does not validate or transcode — it only wraps base64Encode.
close({int? code, String? reason}) Future<void>
Closes the WebSocket connection.
closeSession({String? eventId}) → void
Gracefully closes the translation session. The server flushes any pending input audio and emits any remaining translated output before closing the socket.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
send(Map<String, dynamic> event) → void
Sends a raw client event to the server.
toString() String
A string representation of this object.
inherited
updateSession(RealtimeTranslationSessionUpdateRequest config, {String? eventId}) → void
Updates the translation session's configuration.

Operators

operator ==(Object other) bool
The equality operator.
inherited