How Language Translation Works
Sanas Language Translation turns speech in one language into natural-sounding speech in another, in real time. You send audio in, and you get translated audio back — along with the text of what was said and what it was translated to. Access is enabled through the Sanas Developer Console. Once Language Translation is turned on for your account there, you’ll generate an API key and pick the languages you want to translate between. No separate installation or infrastructure is required on your side. Under the hood, each session follows a simple round trip:- Your app captures audio — from a microphone or an audio file — and opens a connection to the Sanas cloud using WebRTC or WebSocket (or the Sanas JavaScript client, which handles the connection for you).
- You choose a language route, such as English → Spanish, and the session starts once the service confirms it’s ready.
- Sanas processes the speech in the cloud: it transcribes what was said (speech-to-text), translates the text into the target language, and generates spoken audio in a natural voice (text-to-speech).
- Translated audio streams back to your app, ready to play, along with live transcription and translation text you can display on screen.
Supported Languages:
Before You Start
You need:- A Sanas API key or access token.
- The Sanas API base URL:
https://api.sanaslt.com. - A source language and target language route, such as
en-UStoes-ES. - A browser or client environment that can capture and play audio.
Choose an Integration Path
JavaScript Client
Use the JavaScript client for web applications and prototypes. It wraps the WebRTC and WebSocket transports, manages the connection lifecycle, and exposes callbacks for transcript, translation, and audio events.Direct WebRTC API
Use WebRTC when you want browser-native media tracks, Opus audio, and lower-latency playback. The signaling endpoint is:Direct WebSocket API
Use the WebSocket API when you want a single persistent connection and can send raw PCM audio frames yourself. The stream endpoint is:Stream Session Basics
Both WebRTC and WebSocket use the same Stream message layer:- Open an authenticated transport connection.
- Send an
initmessage with session settings. - Send a
configuremessage with language routes and features. - Wait for the server to return
configured. - Stream input audio.
- Listen for transcription, translation, lifecycle, and output audio events.
- Send
flushwhen you want to finalize a turn manually.
REST API
Use REST endpoints for non-streaming operations, including health checks, error codes, language listing, device registration, and Twilio integration. REST endpoints use the base URL:Authentication
Streaming APIs accept either an API key or a JWT access token as a query parameter:Next Steps
- Start from the Language Translation Demo if you are building a browser app.
- Read Stream Message Layer before implementing direct WebRTC or WebSocket clients.
- Use WebRTC API for browser media-track integrations.
- Use WebSocket API for custom PCM streaming integrations.
- Use REST API for setup, metadata, and account operations.