Live Translation
VALSEA provides a real-time speech-to-text and translation API via WebSocket — stream audio in one language and receive both the original transcript and a live translation into your target language.
Connection
Endpoint: wss://api.valsea.ai/v1/realtime/translate
Authentication
You must authenticate the WebSocket connection by passing your API key in the HTTP headers during the handshake.
Headers:
Authorization:Bearer YOUR_API_KEY(Recommended)X-API-Key:YOUR_API_KEY(Supported)
Browser clients can also authenticate with ?api_key=YOUR_API_KEY because standard browser
WebSocket constructors do not support custom headers.
Paid Rate-Limit Bypass
If you need to exceed the realtime connection RPM limit for a session, you can bypass the rate-limit check by sending one of these opt-in flags during the WebSocket handshake:
- Header:
X-Bypass-Rate-Limit: true - Query parameter:
bypass_rate_limit=true - Query parameter:
bypassRateLimit=true
Bypass applies only to the per-organization rate-limit check. Authentication, credit checks, and
session billing still apply. RTT sessions using this bypass are billed at 2x the normal realtime
credit cost. The initial session.created event includes rateLimitBypass: true and
billingMultiplier: 2 when bypass is active. If speaker diarization is also enabled for the session,
the final session cost is 4x the normal realtime credit cost.
Message Flow
- Connect: Client establishes WebSocket connection.
- Session Created: Server sends
session.createdevent. - Start Session: Client sends
session.startto configure language, target language, and model. - Stream Audio: Client sends
audio.appendmessages with base64-encoded PCM16 audio chunks. - Receive Transcripts: Server streams
transcript.partialandtranscript.finalevents —transcript.finalincludes the translation oncetarget_languageis set. - Commit Audio: Client sends
audio.commitwhen a user stops speaking (optional/VAD dependent). - Stop Session: Client sends
session.stopto end the session.
Partial vs Final (Important)
RTT emits two transcript event types for each utterance:
transcript.partial: low-latency, in-progress text in the original language. This can change as more audio arrives. Partials are never translated.transcript.final: stable text for a completed segment — translated, iftarget_languagewas requested. Treat this as the committed result.
Recommended client behavior:
- Keep a temporary
currentPartialstring fortranscript.partial. - Append only
transcript.finalto your persisted transcript history. - Clear
currentPartialwhen you receive a matchingtranscript.final.
Do not persist partial text as final output. Partials are intentionally mutable and may be revised by the engine before a final segment is produced.
Client Messages
session.start
Initialize the session with configuration.
{
"type": "session.start",
"model": "valsea-rtt",
"hint_text": "Optional context or vocabulary",
"enable_correction": true,
"language": "auto",
"target_language": "spanish",
"noise_suppression": "off"
}
| Field | Type | Description |
|---|---|---|
model | string | Model to use (e.g., valsea-rtt). |
hint_text | string | Optional list of words or context to improve accuracy. |
enable_correction | boolean | Enable post-processing for grammar/language correction (default: true). |
language | string | Language hint, or auto for code-switch-aware auto-detection. |
target_language | string | Translation target for the final transcript text. Also accepted as targetLanguage. Omit it to receive transcription only. |
noise_suppression | string | "off" (default) or "rnnoise" — runs incoming audio through noise suppression before transcription. |
When target_language is set and differs from the input language, transcript.final.text is
translated to that target language, and rawText holds the original transcript. Partial transcripts
are never translated. Supported translation targets are english, chinese, japanese, korean,
vietnamese, thai, french, spanish, german, russian, indonesian, malay, filipino,
tamil, khmer, and lao.
An unsupported or malformed target_language returns INVALID_TRANSLATION_TARGET and ends the
session — see the error example below. Double-check the value against the supported list before
sending it.
audio.append
Send audio data.
{
"type": "audio.append",
"audio": "BASE64_ENCODED_PCM16_DATA"
}
- Format: Raw PCM 16-bit, 16kHz (recommended), mono.
- Encoding: Base64 string.
You may also send raw binary PCM16 frames directly over the WebSocket. Binary frames are treated as
audio.append messages by the server.
audio.commit
Signal the end of a speech segment (e.g., VAD triggered silence).
{
"type": "audio.commit"
}
session.stop
End the session gracefully.
{
"type": "session.stop"
}
Server Messages
session.created
Sent immediately upon connection.
{
"type": "session.created",
"sessionId": "rtt_...",
"supportedModels": ["valsea-rtt"]
}
session.ready
Sent when the backend engine is connected and ready to receive audio.
{
"type": "session.ready",
"sessionId": "rtt_...",
"engine": "valsea-7"
}
engine is an opaque identifier for the backend that handled your session.
transcript.partial
Intermediate transcription results, in the original language (low latency, may change).
{
"type": "transcript.partial",
"text": "The quick brown",
"isFinal": false,
"timestampMs": 1888
}
transcript.final
Finalized text for a speech segment. Without translation:
{
"type": "transcript.final",
"text": "The quick brown fox jumps over the lazy dog while the market",
"rawText": "The quick brown fox jumps over the lazy dog while the market",
"isFinal": true,
"timestampMs": 3765
}
With target_language set — real, captured output translating English to Spanish:
{
"type": "transcript.final",
"text": "El rápido zorro marrón salta sobre el perro perezoso mientras el mercado",
"rawText": "The quick brown fox jumps over the lazy dog while the market",
"isFinal": true,
"timestampMs": 3765,
"translated": true,
"sourceLanguage": "english",
"targetLanguage": "spanish"
}
When translated: true, text is the translation and rawText is the original
transcript — easy to mix up if you're not checking the flag.
error
Sent when an error occurs.
{
"type": "error",
"code": "INVALID_MESSAGE",
"message": "Failed to parse message"
}
Real example — invalid translation target. Captured during testing: "chinese" normalizes
internally to "chinese-mandarin", which isn't in the allowed target list, so the session ends:
{
"type": "error",
"code": "INVALID_TRANSLATION_TARGET",
"message": "Translation target language 'chinese-mandarin' is not supported"
}
{
"type": "session.ended",
"reason": "invalid_translation_target",
"error": "Translation target language 'chinese-mandarin' is not supported"
}
Error codes on this endpoint
| Code | Fires when | Recoverable? |
|---|---|---|
AUTH_REQUIRED | No API key provided on connect | No — reconnect with a key |
AUTH_FAILED | Invalid API key, or key has no associated organization | No — reconnect with a valid key |
RATE_LIMITED | Org exceeded RTT connections-per-minute | Yes — retry after retryAfterMs |
INSUFFICIENT_CREDITS | Org credit balance is ≤ 0 | No — until credits are topped up |
INVALID_MESSAGE | A client message couldn't be parsed as JSON | Yes — session stays open |
INVALID_TRANSLATION_TARGET | Unsupported/unrecognized target_language | No — session ends |
ALL_ENGINES_FAILED | No transcription backend could be initialized for the requested language | No — session ends |
NOT_READY | audio.append sent before session.ready | Yes — wait for session.ready |
AUTO_ROUTE_ERROR | Auto-detection failed for a specific utterance (language: "auto" only) | Yes — subsequent turns unaffected |
Event Handling Pattern
Use this pattern to avoid duplicated or unstable transcript content:
let currentPartial = '';
const finalSegments = [];
ws.on('message', (raw) => {
const msg = JSON.parse(raw);
if (msg.type === 'transcript.partial') {
currentPartial = msg.text || '';
}
if (msg.type === 'transcript.final') {
finalSegments.push(msg.text || '');
currentPartial = '';
}
});
Example (Node.js)
const WebSocket = require('ws');
const fs = require('fs');
const ws = new WebSocket('wss://api.valsea.ai/v1/realtime/translate', {
headers: { 'X-API-Key': 'YOUR_KEY' },
});
ws.on('open', () => {
ws.send(
JSON.stringify({
type: 'session.start',
model: 'valsea-rtt',
language: 'auto',
target_language: 'spanish',
}),
);
});
ws.on('message', (data) => {
const msg = JSON.parse(data);
if (msg.type === 'session.ready') {
const audioStream = fs.createReadStream('audio.raw');
audioStream.on('data', (chunk) => {
ws.send(
JSON.stringify({
type: 'audio.append',
audio: chunk.toString('base64'),
}),
);
});
} else if (msg.type === 'transcript.final') {
console.log('Original:', msg.rawText);
console.log('Translated:', msg.text);
}
});
Model Selection Guide
Default: Auto-Detect
Use language: "auto" to automatically detect and transcribe speech across 100+ languages, with
built-in support for code-switching — the language can change mid-conversation (or mid-sentence)
without losing accuracy.
{
"language": "auto"
}
Best for:
- Multi-language or unknown input
- Conversations where speakers switch languages mid-utterance
- Global applications
- Fast setup with minimal tuning
For a Fixed Language
If you already know the language being spoken, set it explicitly for the most consistent routing:
{
"model": "valsea-rtt",
"language": "singlish"
}
List of Languages
Southeast Asia
Singlish — singlish
Indonesian — indonesian
Malaysian — malay
Vietnamese — vietnamese
Thai — thai
Javanese — javanese
Lao — lao
Khmer — khmer
Filipino/Tagalog — filipino
English (Philippines) — english-philippines
Middle East & North Africa
Arabic — arabic arabic-algeria arabic-bahrain arabic-egypt arabic-israel arabic-jordan arabic-kuwait arabic-lebanon arabic-mauritania arabic-morocco arabic-oman arabic-palestine arabic-qatar arabic-saudi arabic-syria arabic-tunisia arabic-uae arabic-yemen
Persian — persian
Hebrew — hebrew
Amharic — amharic
Wolof — wolof
Sub-Saharan Africa
Swahili — swahili swahili-ke
Afrikaans — afrikaans
Akan — akan
Bemba — bemba
Fulani — fulani
Ga — ga
Hausa — hausa
Igbo — igbo
Luganda — luganda
Xhosa — xhosa
Yoruba — yoruba
Zulu — zulu
Northern Sotho — northern-sotho
Nyankole — nyankole
Oromo — oromo
Pidgin — pidgin
Kinyarwanda — kinyarwanda
Shona — shona
Sotho — sotho
Tswana — tswana
Twi — twi
South Asia
Bengali — bengali-bd bengali-in
Hindi — hindi
Gujarati — gujarati
Kannada — kannada
Malayalam — malayalam
Marathi — marathi
Nepali — nepali
Oriya — oriya
Punjabi — punjabi
Sinhala — sinhala
Tamil — tamil
Telugu — telugu
Assamese — assamese
East Asia
Chinese — cantonese chinese chinese-simplified chinese-traditional
Covers a wide range of regional accents and dialects, including those from Anhui, Beijing, Chongqing, Gansu, Guangdong, Guangxi, Guizhou, Hangzhou, Hebei, Henan, Hong Kong, Hubei, Jiangsu, Jianghuai, Jiaoliao, Jilu, Lanyin, Nanjing, Northeast, Ningxia, Shaanxi, Shandong, Sichuan, Taiwan, Tianjin, and Yunnan.
Japanese — japanese
Korean — korean
Mongolian — mongolian
Central & Western Asia
Azerbaijani — azerbaijani
Armenian — armenian
Georgian — georgian
Kazakh — kazakh
Kurdish — kurdish
Kyrgyz — kyrgyz
Uzbek — uzbek
Turkish — turkish
Western Europe
English — english english-au english-gb english-in english-philippines english-us
French — french french-ca
Spanish — spanish spanish-es spanish-mexico spanish-us
Portuguese — portuguese portuguese-br
German — german
Dutch — dutch
Italian — italian
Catalan — catalan
Galician — galician
Asturian — asturian
Basque — basque
Welsh — welsh
Luxembourgish — luxembourgish
Maltese — maltese
Northern Europe
Danish — danish
Finnish — finnish
Icelandic — icelandic
Norwegian — norwegian
Swedish — swedish
Estonian — estonian
Latvian — latvian
Lithuanian — lithuanian
Eastern Europe & Balkans
Bulgarian — bulgarian
Croatian — croatian
Czech — czech
Hungarian — hungarian
Macedonian — macedonian
Polish — polish
Romanian — romanian
Russian — russian
Serbian — serbian
Slovak — slovak
Slovenian — slovenian
Ukrainian — ukrainian
Albanian — albanian
Greek — greek
Pacific & Oceania
Maori — maori