Skip to content

Real-time translation

The problem. A support agent in Paris, a customer speaking Spanish; a conference streamed to an international audience. Translation turns each sentence into the languages you choose while the person is still speaking: live subtitles, a bilingual call log, a meeting record in your team’s language.

Where it works. solaria-3 only. The translation is made from the audio of each utterance, not from its transcript.

To hear it, in the speaker’s voice and a few words behind them, see Speech translation.

Live APIrealtime_processing.translation
Pre-recorded (batch)translation (how)
Live modelssolaria-3 (every live model)
LanguagesSpeech in every language of the model, translated into the target languages
{
"model": "solaria-3",
"realtime_processing": {
"translation": true,
"translation_config": { "target_languages": ["en", "fr"] }
}
}

Each program streams a 16-bit WAV file and prints what comes back. Put your API key in the GLADIA_API_KEY environment variable, then run python translation.py meeting.wav.

translation.py
# pip install "gladiaio-sdk>=2.2"
import os
import sys
import threading
import wave
from gladiaio_sdk import GladiaClient, LiveV2InitRequest
API_URL = os.environ.get("GLADIA_API_URL", "https://eu1.api.gladia.io")
API_KEY = os.environ["GLADIA_API_KEY"]
with wave.open(sys.argv[1]) as wav: # a 16-bit PCM WAV file
rate, channels = wav.getframerate(), wav.getnchannels()
audio = wav.readframes(wav.getnframes())
config = {
"encoding": "wav/pcm",
"sample_rate": rate,
"bit_depth": 16,
"channels": channels,
"model": "solaria-3",
"language_config": {
"languages": [
"es"
]
},
"realtime_processing": {
"translation": True,
"translation_config": {
"target_languages": [
"en",
"fr"
]
}
}
}
client = GladiaClient(api_key=API_KEY, api_url=API_URL)
session = client.live_v2().start_session(LiveV2InitRequest.from_dict(config))
ended, errors = threading.Event(), []
@session.on("message")
def on_message(message):
if message.type == "transcript" and message.data.is_final:
print(message.data.utterance.text)
elif message.type == "translation" and message.data.translated_utterance:
translated = message.data.translated_utterance
print(f" {translated.language}: {translated.text}")
session.on("error", errors.append)
session.once("ended", lambda _: ended.set())
# Stream once the socket is open: a stop sent while it opens can pass the audio queued until then.
connected = threading.Event()
session.once("connected", lambda _: connected.set())
session.once("ended", lambda _: connected.set()) # a session that never connects ends
session.on("error", lambda _: connected.set())
if session.status == "connected": # it opened before the listener above
connected.set()
if not connected.wait(timeout=30) or errors or ended.is_set():
sys.exit(1) # no open session to stream to
step = rate * channels * 2 // 10 # 100 ms of audio per chunk
for start in range(0, len(audio), step):
session.send_audio(audio[start : start + step]) # live audio: send each chunk as it is captured
session.stop_recording()
ended.wait(timeout=60)
sys.exit(1 if errors or not ended.is_set() else 0)

Each final transcript is followed by one translation message per target language:

{
"type": "translation",
"session_id": "0199d7a2-5c3e-7b41-9f0a-3c2d1e4f5a6b",
"error": null,
"data": {
"utterance_id": "00_00000003",
"utterance": { "text": "¿Dónde está la estación?", "start": 12.4, "end": 13.9, "language": "es", "channel": 0 },
"original_language": "es",
"target_language": "en",
"translated_utterance": { "text": "Where is the station?", "start": 12.4, "end": 13.9, "language": "en", "channel": 0, "confidence": 1, "words": [] }
}
}

The session’s result (GET /v2/live/{id}, post_final_transcript) has a translation block: one result per target language, with its utterances and full text.

The problem. “Can you send it?” is “Peux-tu l’envoyer ?” to a friend and “Pouvez-vous l’envoyer ?” to a customer. “The failure is getting worse” is l’échec in a business meeting and l’insuffisance in a cardiology consultation. Two options of translation_config tell the translation which one you mean:

  • informal: true: the informal register where the target language has one (French tu, German du, Spanish tú, Dutch jij). Without it, the model picks the register the sentence implies, usually the formal one.
  • context: a free-text hint on the conversation (its domain, who speaks, the terms it uses), up to 4096 characters. It helps choose the terms and resolve ambiguities; it is never translated.
  • context_adaptation: false: a literal translation, sentence by sentence: the context and the previous sentences are not used.
{
"model": "solaria-3",
"realtime_processing": {
"translation": true,
"translation_config": {
"target_languages": ["fr", "de"],
"informal": true,
"context": "A support call between a games company and one of its young players."
}
}
}

How it works. Both are applied by the translation LLM, which translates each final from its text (the workspace’s own LLM, set in its console, else the deployment’s translation LLM): a session that asks for either gets every target from the LLM, as with mode: "cascade". The speech translation model, which translates from the audio, takes neither.

What it changes, for example on 8 second-person sentences per language:

target without informal with informal: true
French tu 2/8, vous 6/8 tu 8/8, vous 0/8
German du 6/8, Sie 2/8 du 8/8, Sie 0/8

With context: "A cardiology consultation...": “The failure is getting worse” becomes L’insuffisance s’aggrave (L’échec s’aggrave without it), “check the rate” vérifier la fréquence cardiaque (la fréquence).

They need a translation LLM on the gateway. Support is decided by that LLM, not by an option of yours: the workspace’s own LLM (its console), else the LLM your operator routed translation to in the gateway’s the LLM your operator connected and routed to translation in the gateway’s LLM providers (the on-premise guide’s LLM providers page), else the cluster’s translation LLM. When none is configured, the request is refused, clearly, and never translated without the option:

case answer
no translation LLM configured on the gateway 400, realtime_processing.translation_config.informal: not supported: no LLM is configured on this gateway (same for context)
a translation LLM is configured applied: every target is translated by that LLM from the final’s text
mode: "direct", or a spoken session (speech) 400: they translate from the audio, which takes no register nor context
context longer than 4096 characters 400

Your workspace’s LLM settings, and the operator’s LLM providers page, say whether one is there. With the LLM configured but unreachable at the session’s start, the WebSocket closes 1011 rejected: translation: informal needs an LLM ...: retry, or ask your operator to test the LLM.

  • One translation per final. A final is translated once it closes: on a talk read at a steady pace, with no pause as long as endpointing, a final spans several sentences and its translation comes late. Send "finals": "sentence" to close a final at each sentence end (which event closes a final).
  • A little later. An LLM translation arrives a bit after the speech model’s would (one LLM call per final).
  • Same language, same text. An utterance already in a target language comes back as transcribed, in its own register.
  • solaria-3 only. With another model, the session is refused at creation: POST /v2/live answers 400 translation is not available with model … in region eu: use solaria-3. Retrying will not help: change the model.
  • Only the languages the deployment serves. A target no endpoint of the model translates into is refused at creation: POST /v2/live answers 400 translation target pl is not available with model solaria-3 in region eu: use … (or no model in region eu translates into pl). Retrying will not help: drop the target or use the model it names. On a deployment whose containers predate this check, the code passes the creation and the session is refused when it starts: the WebSocket closes with code 1011 and the reason rejected: translation: target language(s) [...] not served. That session ends refused, not failed: it is your request to fix, not an outage.
  • With PII redaction, translations are redacted too. The translation is made from the audio, so the values a final masked would come back in it: a session with both pii and translation runs its PII policy on each translation before it is sent (same entities, mode and threshold). A masked value keeps its id from the final (<pii:name id="1"/> in both). When the redaction fails, or a translation would still hold a masked value, the translation comes with error set and no text: it is withheld, never sent in clear (with mode: tag, which hides nothing, a translation whose tagging fails comes untagged instead).
  • Finals only. Partials are not translated. Translations arrive shortly after their final, never before it, and never delay it.
  • Same language, same text. An utterance already in a target language comes back as transcribed.
  • Long utterances. Translation reads up to 60 seconds of an utterance: set maximum_duration_without_endpointing (at most 60) for monologues without pauses.
  • A translation can fail alone. It then comes with error set and translated_utterance: null; the transcript is not affected. Show the original text as a fallback.
  • At the end, the session waits up to 5 seconds for the last translations before end_session.
  • Spelling and vocabulary do not apply to translations (they come from the audio).
  • Accepted, not applied, deprecated. The field lipsync of translation_config, from Gladia Classic (Gladia’s cloud API, api.gladia.io), is accepted and has no effect: every translation follows its final’s utterance. So does match_original_utterances, true (the default) or false: every translated utterance matches a transcribed one, live and pre-recorded. Both are kept only for clients migrated from Gladia Classic. Do not use them in new integrations: they may be removed (decommissioned) in a future release. Remove them (Deprecated Gladia Classic compatibility). informal, context and context_adaptation are applied (Register and context); on pre-recorded jobs, informal: true is not supported yet (400).
Target languageCode
Afrikaansaf
Amharicam
Arabicar
Assameseas
Azerbaijaniaz
Bashkirba
Belarusianbe
Bulgarianbg
Banglabn
Tibetanbo
Bretonbr
Bosnianbs
Catalanca
Czechcs
Welshcy
Danishda
Germande
Greekel
Englishen
Spanishes
Estonianet
Basqueeu
Persianfa
Finnishfi
Filipinofil
Faroesefo
Frenchfr
Galiciangl
Gujaratigu
Hausaha
Hawaiianhaw
Hebrewhe
Hindihi
Croatianhr
Haitian Creoleht
Hungarianhu
Armenianhy
Indonesianid
Icelandicis
Italianit
Japaneseja
Javanesejv
Georgianka
Kazakhkk
Khmerkm
Kannadakn
Koreanko
Latinla
Luxembourgishlb
Lingalaln
Laolo
Lithuanianlt
Latvianlv
Malagasymg
Māorimi
Macedonianmk
Malayalamml
Mongolianmn
Marathimr
Malayms
Maltesemt
Burmesemy
Nepaline
Dutchnl
Norwegian Nynorsknn
Norwegianno
Occitanoc
Punjabipa
Polishpl
Pashtops
Portuguesept
Romanianro
Russianru
Sanskritsa
Sindhisd
Sinhalasi
Slovaksk
Sloveniansl
Shonasn
Somaliso
Albaniansq
Serbiansr
Sundanesesu
Swedishsv
Swahilisw
Tamilta
Telugute
Tajiktg
Thaith
Turkmentk
Filipinotl
Turkishtr
Tatartt
Ukrainianuk
Urduur
Uzbekuz
Vietnamesevi
Wolofwo
Yiddishyi
Yorubayo
Chinesezh
Chinese (Taiwan)zh-tw
symptom cause fix
400 “translation is not available with model …” at creation the model is not solaria-3 set "model": "solaria-3"
400 “translation target … is not available with model …” at creation no endpoint of the model translates into that target drop it, or use the model the message names
WebSocket closed 1011 “rejected: translation: target language(s)…” a target not in the list (older containers) use the codes above
a translation with error “pii redaction failed, the text is withheld” pii on, the redaction of that translation failed or missed a masked value expected: the text is never sent in clear; show the redacted final instead
no translation message messages_config.receive_realtime_processing_events: false turn it back on, or read the session’s result
400 “…translation_config.informal: not supported: no LLM is configured on this gateway” no translation LLM on the gateway set the workspace’s LLM, or ask your operator to route translation to one
400 “…translation_config.informal: not supported: the translation style is switched off on this gateway” the operator’s rollout switch is off ask your operator; or drop informal / context
WebSocket closed 1011 “rejected: translation: informal needs an LLM” no LLM translates for the workspace set the workspace’s LLM in its console, or drop the option