返回首页
Lanson Flow 文档库

Real-time translation: get translated text alongside transcription while speech is happening.

::callout{icon="i-lucide-triangle-alert" color="amber"} Real-time translate_to is not currently enabled for external sessions. The public realtime gateway forwards language but does not forward translate_to, so a session.update with that field has no effect. ::

Usage

Configure translation

Set the source language and translation target via session.update:

{
  "type": "session.update",
  "language": "zh",
  "translate_to": "en"
}
  • language: source language of the audio
  • translate_to: target language for translation
  • Translation output

    When enabled, translation results are returned alongside transcription in the conversation.item.input_audio_transcription.completed event.

    Source and translated text correspondence

    Source and translation for each utterance arrive in the same conversation.item.input_audio_transcription.completed event, ensuring correspondence. No client-side matching needed.

    Switching languages

    Change language at any time during the session:

    { "type": "session.update", "language": "en" }
    

    New utterances after the switch use the new language. In-flight utterances complete with the previous language.

    Latency

    Translation adds additional latency:

    | Component | Typical p50 | |---|---| | STT (transcription) | ~310ms | | Translation | ~200ms | | End-to-end | ~510ms |

    Translation latency depends on audio length, context, and service load. Measured data on [Service Status](https://control.lansonai.com/status/lanson-audio).

    Multilingual / code-switching

  • Auto-detect: set language: "auto"
  • Mixed language: upstream supports code-switching, accuracy depends on model and audio quality
  • Chinese aliases: zh-cn, zh-tw, mandarin etc. are normalized to zh
  • UI strategy

    1. Receive conversation.item.input_audio_transcription.completed event 2. Display source text on first line 3. Display translation on second line 4. Each utterance is independent, no replacement needed

    See [Build Live Translation](/docs/guides/live-translation) for a detailed guide.

    Related

  • [Session Configuration](/docs/realtime/session-configuration) — session.update details
  • [Live Translation](/docs/concepts/live-translation) — translation concepts
  • [Build Live Translation](/docs/guides/live-translation) — UI guide