SPB Git

Repository Public

translation-client-events.md 4.3 KB 167 lines markdown

1# Realtime translation client events23> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.45These are events that the OpenAI Realtime Translation WebSocket server will accept from the client.67<a id="session.update"></a>89## session.update1011Send this event to update the translation session configuration. Translation12sessions support updates to `audio.output.language`, `audio.input.transcription`,13and `audio.input.noise_reduction`.1415### Schema1617Schema name: `RealtimeTranslationClientEventSessionUpdate`1819- `session: RealtimeTranslationSessionUpdateRequest`2021  Translation session fields to update. The session `type` and `model` are set22  at creation and cannot be changed with `session.update`.2324  - `audio: optional object { input, output }`2526    Configuration for translation input and output audio.2728    - `input: optional object { noise_reduction, transcription }`2930      - `noise_reduction: optional object { type }  or null`3132        Optional input noise reduction. Set to `null` to disable it.3334        - `type: NoiseReductionType`3536          Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.3738          - `"near_field"`3940          - `"far_field"`4142      - `transcription: optional object { model }  or null`4344        Optional source-language transcription. When configured, the server emits45        `session.input_transcript.delta` events. Translation itself still runs from46        the input audio stream.4748        - `model: string`4950          The transcription model to use for source transcript deltas.5152    - `output: optional object { language }`5354      - `language: optional string`5556        Target language for translated output audio and transcript deltas.5758- `type: "session.update"`5960  The event type, must be `session.update`.6162  - `"session.update"`6364- `event_id: optional string`6566  Optional client-generated ID used to identify this event.6768### Example6970```json71{72  "type": "session.update",73  "session": {74    "audio": {75      "input": {76        "transcription": {77          "model": "gpt-realtime-whisper"78        },79        "noise_reduction": null80      },81      "output": {82        "language": "es"83      }84    }85  }86}87```8889<a id="session.input_audio_buffer.append"></a>9091## session.input_audio_buffer.append9293Send this event to append audio bytes to the translation session input audio buffer.9495WebSocket translation sessions accept base64-encoded 24 kHz PCM16 mono96little-endian raw audio bytes. Unsupported websocket audio formats return a97validation error because lower-quality audio materially degrades translation98quality.99100Translation consumes 200 ms engine frames. For best realtime behavior, append101audio in 200 ms chunks. If a chunk is shorter, the server buffers it until it102has enough audio for one frame. If a chunk is longer, the server splits it into103200 ms frames and enqueues them back-to-back.104105Keep appending silence while the session is active. If a client stops sending106audio and later resumes, model time treats the resumed audio as contiguous with107the previous audio rather than as a real-world pause.108109### Schema110111Schema name: `RealtimeTranslationClientEventInputAudioBufferAppend`112113- `audio: string`114115  Base64-encoded 24 kHz PCM16 mono audio bytes.116117- `type: "session.input_audio_buffer.append"`118119  The event type, must be `session.input_audio_buffer.append`.120121  - `"session.input_audio_buffer.append"`122123- `event_id: optional string`124125  Optional client-generated ID used to identify this event.126127### Example128129```json130{131  "event_id": "event_456",132  "type": "session.input_audio_buffer.append",133  "audio": "Base64EncodedAudioData"134}135```136137<a id="session.close"></a>138139## session.close140141Gracefully close the realtime translation session. The server flushes pending142input audio and emits any remaining translated output before closing the143session.144145### Schema146147Schema name: `RealtimeTranslationClientEventSessionClose`148149- `type: "session.close"`150151  The event type, must be `session.close`.152153  - `"session.close"`154155- `event_id: optional string`156157  Optional client-generated ID used to identify this event.158159### Example160161```json162{163  "event_id": "event_789",164  "type": "session.close"165}166```167
Files main
Menu

Theme