Class RealtimeTranslationClientEvent

    • Constructor Detail

    • Method Detail

      • 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.

      • asSessionUpdate

         final RealtimeTranslationSessionUpdateEvent asSessionUpdate()

        Send this event to update the translation session configuration. Translation sessions support updates to audio.output.language, audio.input.transcription, and audio.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.

      • 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.

      • 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.