Class RealtimeTranslationClientEvent
-
- All Implemented Interfaces:
public final class RealtimeTranslationClientEventA Realtime translation client event.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceRealtimeTranslationClientEvent.VisitorAn interface that defines how to map each variant of RealtimeTranslationClientEvent to a value of type T.
-
Method Summary
Modifier and Type Method Description final Optional<RealtimeTranslationSessionUpdateEvent>sessionUpdate()Send this event to update the translation session configuration. final Optional<RealtimeTranslationInputAudioBufferAppendEvent>sessionInputAudioBufferAppend()Send this event to append audio bytes to the translation session input audio buffer. final Optional<RealtimeTranslationSessionCloseEvent>sessionClose()Gracefully close the realtime translation session. final BooleanisSessionUpdate()final BooleanisSessionInputAudioBufferAppend()final BooleanisSessionClose()final RealtimeTranslationSessionUpdateEventasSessionUpdate()Send this event to update the translation session configuration. final RealtimeTranslationInputAudioBufferAppendEventasSessionInputAudioBufferAppend()Send this event to append audio bytes to the translation session input audio buffer. final RealtimeTranslationSessionCloseEventasSessionClose()Gracefully close the realtime translation session. final Optional<JsonValue>_json()final <T extends Any> Taccept(RealtimeTranslationClientEvent.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final RealtimeTranslationClientEventvalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static RealtimeTranslationClientEventofSessionUpdate(RealtimeTranslationSessionUpdateEvent sessionUpdate)Send this event to update the translation session configuration. final static RealtimeTranslationClientEventofSessionInputAudioBufferAppend(RealtimeTranslationInputAudioBufferAppendEvent sessionInputAudioBufferAppend)Send this event to append audio bytes to the translation session input audio buffer. final static RealtimeTranslationClientEventofSessionClose(RealtimeTranslationSessionCloseEvent sessionClose)Gracefully close the realtime translation session. -
-
Method Detail
-
sessionUpdate
final Optional<RealtimeTranslationSessionUpdateEvent> sessionUpdate()
Send this event to update the translation session configuration. Translation sessions support updates to
audio.output.language,audio.input.transcription, andaudio.input.noise_reduction.
-
sessionInputAudioBufferAppend
final Optional<RealtimeTranslationInputAudioBufferAppendEvent> sessionInputAudioBufferAppend()
Send this event to append audio bytes to the translation session input audio buffer.
WebSocket translation sessions accept base64-encoded 24 kHz PCM16 mono little-endian raw audio bytes. Unsupported websocket audio formats return a validation error because lower-quality audio materially degrades translation quality.
Translation consumes 200 ms engine frames. For best realtime behavior, append audio in 200 ms chunks. If a chunk is shorter, the server buffers it until it has enough audio for one frame. If a chunk is longer, the server splits it into 200 ms frames and enqueues them back-to-back.
Keep appending silence while the session is active. If a client stops sending audio and later resumes, model time treats the resumed audio as contiguous with the previous audio rather than as a real-world pause.
-
sessionClose
final Optional<RealtimeTranslationSessionCloseEvent> sessionClose()
Gracefully close the realtime translation session. The server flushes pending input audio and emits any remaining translated output before closing the session.
-
isSessionUpdate
final Boolean isSessionUpdate()
-
isSessionInputAudioBufferAppend
final Boolean isSessionInputAudioBufferAppend()
-
isSessionClose
final Boolean isSessionClose()
-
asSessionUpdate
final RealtimeTranslationSessionUpdateEvent asSessionUpdate()
Send this event to update the translation session configuration. Translation sessions support updates to
audio.output.language,audio.input.transcription, andaudio.input.noise_reduction.
-
asSessionInputAudioBufferAppend
final RealtimeTranslationInputAudioBufferAppendEvent asSessionInputAudioBufferAppend()
Send this event to append audio bytes to the translation session input audio buffer.
WebSocket translation sessions accept base64-encoded 24 kHz PCM16 mono little-endian raw audio bytes. Unsupported websocket audio formats return a validation error because lower-quality audio materially degrades translation quality.
Translation consumes 200 ms engine frames. For best realtime behavior, append audio in 200 ms chunks. If a chunk is shorter, the server buffers it until it has enough audio for one frame. If a chunk is longer, the server splits it into 200 ms frames and enqueues them back-to-back.
Keep appending silence while the session is active. If a client stops sending audio and later resumes, model time treats the resumed audio as contiguous with the previous audio rather than as a real-world pause.
-
asSessionClose
final RealtimeTranslationSessionCloseEvent asSessionClose()
Gracefully close the realtime translation session. The server flushes pending input audio and emits any remaining translated output before closing the session.
-
accept
final <T extends Any> T accept(RealtimeTranslationClientEvent.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import com.openai.core.JsonValue; import java.util.Optional; Optional<String> result = realtimeTranslationClientEvent.accept(new RealtimeTranslationClientEvent.Visitor<Optional<String>>() { @Override public Optional<String> visitSessionUpdate(RealtimeTranslationSessionUpdateEvent sessionUpdate) { return Optional.of(sessionUpdate.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final RealtimeTranslationClientEvent validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
ofSessionUpdate
final static RealtimeTranslationClientEvent ofSessionUpdate(RealtimeTranslationSessionUpdateEvent sessionUpdate)
Send this event to update the translation session configuration. Translation sessions support updates to
audio.output.language,audio.input.transcription, andaudio.input.noise_reduction.
-
ofSessionInputAudioBufferAppend
final static RealtimeTranslationClientEvent ofSessionInputAudioBufferAppend(RealtimeTranslationInputAudioBufferAppendEvent sessionInputAudioBufferAppend)
Send this event to append audio bytes to the translation session input audio buffer.
WebSocket translation sessions accept base64-encoded 24 kHz PCM16 mono little-endian raw audio bytes. Unsupported websocket audio formats return a validation error because lower-quality audio materially degrades translation quality.
Translation consumes 200 ms engine frames. For best realtime behavior, append audio in 200 ms chunks. If a chunk is shorter, the server buffers it until it has enough audio for one frame. If a chunk is longer, the server splits it into 200 ms frames and enqueues them back-to-back.
Keep appending silence while the session is active. If a client stops sending audio and later resumes, model time treats the resumed audio as contiguous with the previous audio rather than as a real-world pause.
-
ofSessionClose
final static RealtimeTranslationClientEvent ofSessionClose(RealtimeTranslationSessionCloseEvent sessionClose)
Gracefully close the realtime translation session. The server flushes pending input audio and emits any remaining translated output before closing the session.
-
-
-
-