Skip to navigation

liveTranslate

View as MarkdownOpen in Claude

Start, summarize, or stop live translation on the call. Live translation recognizes what each party says, translates it, and speaks the translation to the other party in place of the original audio. The action object takes the same shape as the live_translate SWML method: a single start, summarize, inject, or stop key.

See the translate calls guide for which language each party speaks and for the webhook events.

Parameters

action
Record<string, unknown>Required

The action to perform. Set exactly one of start, summarize, inject, or stop.

action.start
object

Start a live translation session.

action.start.from_lang
stringRequired

One of the two languages of the conversation, such as "es-ES". from_voice speaks it.

action.start.to_lang
stringRequired

The other language of the conversation, such as "en-US". to_voice speaks it.

action.start.direction
string[]Required

The sides of the call to translate: "remote-caller", "local-caller", or both. The order decides which side speaks which language.

action.start.webhook
string

The URL that receives translation events as HTTP POST requests.

action.start.from_voice
stringDefaults to azure.en-US-RyanMultilingualNeural

The voice that speaks translations into from_lang, as <engine>.<voice> with a lowercase engine name, such as "azure.es-ES-ElviraNeural".

action.start.to_voice
stringDefaults to azure.en-US-RyanMultilingualNeural

The voice that speaks translations into to_lang, such as "elevenlabs.josh".

action.start.filter_from
string

A tone filter for speech in from_lang: "polite", "rude", "professional", "shakespeare", "gen-z", or a custom instruction prefixed with "prompt:".

action.start.filter_to
string

A tone filter for speech in to_lang, with the same values as filter_from.

action.start.live_events
booleanDefaults to false

Whether to send each translated utterance to the webhook as it is spoken.

action.start.ai_summary
booleanDefaults to false

Whether to add AI summaries to the event sent to the webhook when the session ends.

action.start.ai_summary_prompt
string

The prompt that tells the AI how to summarize the conversation when ai_summary is enabled.

action.start.speech_engine
stringDefaults to deepgram

The speech recognition engine: "deepgram" or "google".

action.start.speech_timeout
numberDefaults to 60000

The timeout for speech recognition, in milliseconds.

action.start.vad_silence_ms
number

The silence, in milliseconds, that ends an utterance. Defaults to 700 with Deepgram and 500 with Google.

action.start.vad_thresh
numberDefaults to 400

Voice activity detection threshold, from 0 to 1800.

action.summarize
object

Request an AI summary of the conversation so far, while translation continues. Pass an empty object to send the summary to the webhook from start with the default summary prompt.

action.summarize.webhook
string

The URL that receives the summary.

action.summarize.prompt
string

The prompt that tells the AI how to summarize the conversation.

action.inject
object

Insert a message into the session, to be translated and spoken on the call.

action.inject.message
stringRequired

The message to translate and speak.

action.inject.direction
stringRequired

The side of the call: "remote-caller" or "local-caller".

action.stop
object

Stop the live translation session on both sides. Pass an empty object.

options
object

Optional settings for the command.

options.statusUrl
string

A status URL sent with the command. Translation events go to action.start.webhook.

Returns

Promise<Record<string, unknown>> — Server response confirming the operation.

Example

import { RelayClient } from '@signalwire/sdk';
const client = new RelayClient({
project: process.env.SIGNALWIRE_PROJECT_ID!,
token: process.env.SIGNALWIRE_API_TOKEN!,
contexts: ['default']
});
client.onCall(async (call) => {
await call.answer();
// Start live translation between Spanish and English
await call.liveTranslate({
start: {
from_lang: 'es-ES',
to_lang: 'en-US',
direction: ['local-caller', 'remote-caller'],
webhook: 'https://example.com/translation-events',
},
});
// Connect the caller to the other party, then let the call proceed...
await call.waitForEnded();
});
await client.run();