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.
At a glance
Section titled “At a glance”| Live API | realtime_processing.translation |
|---|---|
| Pre-recorded (batch) | translation (how) |
| Live models | solaria-3 (every live model) |
| Languages | Speech in every language of the model, translated into the target languages |
Step by step
Section titled “Step by step”1. Choose the target languages
Section titled “1. Choose the target languages”{ "model": "solaria-3", "realtime_processing": { "translation": true, "translation_config": { "target_languages": ["en", "fr"] } }}2. Start a session with it
Section titled “2. Start a session with it”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.
# pip install "gladiaio-sdk>=2.2"import osimport sysimport threadingimport 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 endssession.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 chunkfor start in range(0, len(audio), step): session.send_audio(audio[start : start + step]) # live audio: send each chunk as it is capturedsession.stop_recording()
ended.wait(timeout=60)sys.exit(1 if errors or not ended.is_set() else 0)// npm install @gladiaio/sdkimport { readFileSync } from "node:fs";import { GladiaClient } from "@gladiaio/sdk";
const { sampleRate, channels, pcm } = readWav(process.argv[2]); // a 16-bit PCM WAV file
const config = { encoding: "wav/pcm", sample_rate: sampleRate, bit_depth: 16, channels, model: "solaria-3", language_config: { languages: [ "es" ] }, realtime_processing: { translation: true, translation_config: { target_languages: [ "en", "fr" ] } }};
const client = new GladiaClient({ apiKey: process.env.GLADIA_API_KEY, apiUrl: process.env.GLADIA_API_URL ?? "https://eu1.api.gladia.io",});const session = client.liveV2().startSession(config);
session.on("message", (message) => { if (message.type === "transcript" && message.data.is_final) console.log(message.data.utterance.text); if (message.type === "translation" && message.data.translated_utterance) { const { language, text } = message.data.translated_utterance; console.log(` ${language}: ${text}`); }});session.on("error", (error) => { console.error(error); process.exitCode = 1;});session.once("ended", () => process.exit());
const step = (sampleRate * channels * 2) / 10; // 100 ms of audio per chunkfor (let start = 0; start < pcm.length; start += step) { session.sendAudio(pcm.subarray(start, start + step)); // live audio: send each chunk as it is captured}session.stopRecording();
function readWav(path) { const file = readFileSync(path); let fmt, pcm; for (let pos = 12; pos < file.length; ) { const id = file.toString("ascii", pos, pos + 4); const size = file.readUInt32LE(pos + 4); if (id === "fmt ") fmt = { channels: file.readUInt16LE(pos + 10), sampleRate: file.readUInt32LE(pos + 12) }; if (id === "data") pcm = file.subarray(pos + 8, pos + 8 + size); pos += 8 + size + (size % 2); } return { ...fmt, pcm };}Create the session, then stream its audio to the returned url (Live WebSocket):
curl -X POST https://eu1.api.gladia.io/v2/live \ -H "x-gladia-key: $GLADIA_API_KEY" \ -H "content-type: application/json" \ -d '{ "encoding": "wav/pcm", "sample_rate": 16000, "bit_depth": 16, "channels": 1, "model": "solaria-3", "language_config": { "languages": [ "es" ] }, "realtime_processing": { "translation": true, "translation_config": { "target_languages": [ "en", "fr" ] } } }'3. Read the translations
Section titled “3. Read the translations”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": [] } }}4. Get them all at the end
Section titled “4. Get them all at the end”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.
Register and context
Section titled “Register and context”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: thecontextand 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.
Limits and gotchas
Section titled “Limits and gotchas”solaria-3only. With another model, the session is refused at creation:POST /v2/liveanswers400translation 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/liveanswers400translation target pl is not available with model solaria-3 in region eu: use …(orno 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 code1011and the reasonrejected: translation: target language(s) [...] not served. That session endsrefused, notfailed: 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
piiandtranslationruns its PII policy on each translation before it is sent (same entities, mode and threshold). A masked value keeps itsidfrom the final (<pii:name id="1"/>in both). When the redaction fails, or a translation would still hold a masked value, the translation comes witherrorset and no text: it is withheld, never sent in clear (withmode: 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
errorset andtranslated_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
lipsyncoftranslation_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 doesmatch_original_utterances,true(the default) orfalse: 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,contextandcontext_adaptationare applied (Register and context); on pre-recorded jobs,informal: trueis not supported yet (400).
Target languages
Section titled “Target languages”| Target language | Code |
|---|---|
| Afrikaans | af |
| Amharic | am |
| Arabic | ar |
| Assamese | as |
| Azerbaijani | az |
| Bashkir | ba |
| Belarusian | be |
| Bulgarian | bg |
| Bangla | bn |
| Tibetan | bo |
| Breton | br |
| Bosnian | bs |
| Catalan | ca |
| Czech | cs |
| Welsh | cy |
| Danish | da |
| German | de |
| Greek | el |
| English | en |
| Spanish | es |
| Estonian | et |
| Basque | eu |
| Persian | fa |
| Finnish | fi |
| Filipino | fil |
| Faroese | fo |
| French | fr |
| Galician | gl |
| Gujarati | gu |
| Hausa | ha |
| Hawaiian | haw |
| Hebrew | he |
| Hindi | hi |
| Croatian | hr |
| Haitian Creole | ht |
| Hungarian | hu |
| Armenian | hy |
| Indonesian | id |
| Icelandic | is |
| Italian | it |
| Japanese | ja |
| Javanese | jv |
| Georgian | ka |
| Kazakh | kk |
| Khmer | km |
| Kannada | kn |
| Korean | ko |
| Latin | la |
| Luxembourgish | lb |
| Lingala | ln |
| Lao | lo |
| Lithuanian | lt |
| Latvian | lv |
| Malagasy | mg |
| Māori | mi |
| Macedonian | mk |
| Malayalam | ml |
| Mongolian | mn |
| Marathi | mr |
| Malay | ms |
| Maltese | mt |
| Burmese | my |
| Nepali | ne |
| Dutch | nl |
| Norwegian Nynorsk | nn |
| Norwegian | no |
| Occitan | oc |
| Punjabi | pa |
| Polish | pl |
| Pashto | ps |
| Portuguese | pt |
| Romanian | ro |
| Russian | ru |
| Sanskrit | sa |
| Sindhi | sd |
| Sinhala | si |
| Slovak | sk |
| Slovenian | sl |
| Shona | sn |
| Somali | so |
| Albanian | sq |
| Serbian | sr |
| Sundanese | su |
| Swedish | sv |
| Swahili | sw |
| Tamil | ta |
| Telugu | te |
| Tajik | tg |
| Thai | th |
| Turkmen | tk |
| Filipino | tl |
| Turkish | tr |
| Tatar | tt |
| Ukrainian | uk |
| Urdu | ur |
| Uzbek | uz |
| Vietnamese | vi |
| Wolof | wo |
| Yiddish | yi |
| Yoruba | yo |
| Chinese | zh |
| Chinese (Taiwan) | zh-tw |
Troubleshooting
Section titled “Troubleshooting”| 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 |