Speech translation API for live audio and recordings
Stream audio and get each sentence back transcribed and translated into up to 10 languages, a second or two after it is spoken. A finished recording can be read in any of the 100 languages, up to 10 per transcription.
npm install @vocalstack/js-sdkimport { VocalStack } from '@vocalstack/js-sdk';
const vs = new VocalStack({ apiKey: process.env.VOCALSTACK_API_KEY });
// A file at full speed here. A microphone streams the same way.
const session = await vs.realtime.connect({
input: { kind: 'file' },
spokenLanguage: 'en',
translate: ['es', 'de'],
sentences: { enabled: true },
});
void session.sendFile('./keynote.mp3');
for await (const ev of session) {
if (ev.type !== 'transcript.sentence' || ev.sentence.status !== 'closed') continue;
const { text, translations } = ev.sentence;
console.log(`${text}\n es: ${translations?.es}\n de: ${translations?.de}`);
}Welcome, everyone, and thank you for coming.
es: Bienvenidos a todos y gracias por venir.
de: Willkommen und danke, dass Sie gekommen sind.
Let's start with what changed this year.
es: Empecemos por lo que cambió este año.
de: Beginnen wir mit dem, was sich dieses Jahr geändert hat.What the translation API does
Translation is included in the per-second price. Ask for languages with translate on a live session, or read any transcript with lang.
Translated while it is spoken
Each line is followed by its translations, usually a second or two later. Change the languages mid-stream with
session.updateand the change applies to what follows.Whole sentences
With
sentenceson, the server joins lines into sentences and translates each one whole. Its translations can still change while the sentence is open and are final once it closes.Up to 10 languages at once
A transcription carries up to 10 languages besides the one spoken, chosen from 100. Leave the spoken language out and the API detects it.
Each listener picks a language
Share a transcription and each listener asks for their own language with
lang=es. Listening is free, however many people follow.Spoken translations
Add
voiceand each translated sentence also arrives as a short audio clip. A speaker is read in a stock voice, or in their own cloned voice when they agreed to it.Recordings and exports
Read a finished transcript in another language with
lang=de, or export it translated as SRT, VTT, PDF, XLSX, TXT, Markdown or JSON.
Endpoints and frames
Live translation runs over one WebSocket. Recordings are read in another language over REST.
- POST
/v1/realtime/sessionsOpen a realtime session withtranslateandsentences, and get the WebSocket address to stream audio to. - WS
transcript.sentenceOne sentence and its translations, keyed bysentenceId: provisional whileopen, final onceclosed. - WS
transcript.voiceA translated sentence read aloud as an Ogg/Opus clip, whenvoiceasks for that language. - GET
/v1/languagesThe languages that can be transcribed, translated into and spoken. - GET
/v1/transcriptions/{id}/transcriptAddlang=esto read a finished transcript in Spanish. - GET
/v1/transcriptions/{id}/exportDownload it translated:lang=eswithformat=srt,vtt,pdf,xlsx,txt,mdorjson.
Billed per second of audio
Translation and spoken translations cost nothing extra. You pay for the audio transcribed, by the second, and listeners are free.
- Pay as you go bills at least 5 minutes for each transcription.
- Premium and Enterprise bill every second with no minimum.
- New accounts get $5 of credit to try it.
Frequently Asked Questions
Guides and related pages
The API reference has complete programs for every SDK and for plain HTTP.