Skip to navigation
RelayCall

live_translate

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 dictionary 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
dictRequired

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

action.start
dict

Start a live translation session.

action.start.from_lang
strRequired

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

action.start.to_lang
strRequired

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

action.start.direction
list[str]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
str

The URL that receives translation events as HTTP POST requests.

action.start.from_voice
strDefaults 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
strDefaults to azure.en-US-RyanMultilingualNeural

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

action.start.filter_from
str

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
str

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

action.start.live_events
boolDefaults to False

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

action.start.ai_summary
boolDefaults to False

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

action.start.ai_summary_prompt
str

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

action.start.speech_engine
strDefaults to deepgram

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

action.start.speech_timeout
intDefaults to 60000

The timeout for speech recognition, in milliseconds.

action.start.vad_silence_ms
int

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

action.start.vad_thresh
intDefaults to 400

Voice activity detection threshold, from 0 to 1800.

action.summarize
dict

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

action.summarize.webhook
str

The URL that receives the summary.

action.summarize.prompt
str

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

action.inject
dict

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

action.inject.message
strRequired

The message to translate and speak.

action.inject.direction
strRequired

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

action.stop
dict

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

status_url
str | NoneDefaults to None

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

Returns

dict — Server response confirming the operation.

Example

from signalwire.relay import RelayClient
client = RelayClient(
project="your-project-id",
token="your-api-token",
contexts=["default"],
)
@client.on_call
async def handle_call(call):
await call.answer()
# Start live translation between Spanish and English
await call.live_translate({
"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.wait_for_ended()
client.run()