live_translate
Translate a voice interaction in real-time.
Name | Type | Default | Description |
---|---|---|---|
live_translate Required | object | - | An object that accepts the live_translate parameters . |
live_translate Parameters
Name | Type | Default | Description |
---|---|---|---|
action Required | string | object | - | The action to be performed. An object that contains one of the live_translate actions Possible Values: [ stop , start , summarize , inject ] |
Example
- Start Example
- Stop Example
- Summarize Example
- Inject Example
In the below example, the SWML script answers an incoming call and then starts recording the call.
The script then starts a live translation session by using the start
action. The script will translate the conversation from English to Spanish.
After the translation session has started, the script connects the call to a destination number.
- YAML
- JSON
sections:
main:
- answer: {}
- record_call:
format: wav
stereo: 'true'
- live_translate:
action:
start:
webhook: 'https://example.com/webhook'
to_voice: elevenlabs.rachel
to_lang: es
direction:
- local-caller
- remote-caller
from_lang: en-US
from_voice: elevenlabs.rachel
live_events: true
ai_summary: true
- connect:
from: '+1XXXXXXXXXX'
to: '+1XXXXXXXXXX'
{
"sections": {
"main": [
{
"answer": {}
},
{
"record_call": {
"format": "wav",
"stereo": "true"
}
},
{
"live_translate": {
"action": {
"start": {
"webhook": "https://example.com/webhook",
"to_voice": "elevenlabs.rachel",
"to_lang": "es",
"direction": [
"local-caller",
"remote-caller"
],
"from_lang": "en-US",
"from_voice": "elevenlabs.rachel",
"live_events": true,
"ai_summary": true
}
}
}
},
{
"connect": {
"from": "+1XXXXXXXXXX",
"to": "+1XXXXXXXXXX"
}
}
]
}
}
In the below example, the SWML script answers an incoming call and then starts recording the call.
The script then initiates a start
action to start a live translation session.
The script then connects the call to a destination number.
After the call is connected, the script plays a message to the caller stating that the translation session is ending.
Finally, the script stops the live translation by passing the stop
action.
- YAML
- JSON
sections:
main:
- answer: {}
- record_call:
format: wav
stereo: 'true'
- live_translate:
action:
start:
webhook: 'https://example.com/webhook'
from_lang: en
from_voice: en-US
live_events: true
direction:
- remote-caller
- local-caller
- connect:
from: '+1XXXXXXXXXX'
to: '+1XXXXXXXXXX'
- play:
url: 'say: Thank you for using the live translation service. We will now end the translation session.'
- live_translate:
action: "stop"
{
"sections": {
"main": [
{
"answer": {}
},
{
"record_call": {
"format": "wav",
"stereo": "true"
}
},
{
"live_translate": {
"action": {
"start": {
"webhook": "https://example.com/webhook",
"from_lang": "en",
"from_voice": "en-US",
"live_events": true,
"direction": [
"remote-caller",
"local-caller"
]
}
}
}
},
{
"connect": {
"from": "+1XXXXXXXXXX",
"to": "+1XXXXXXXXXX"
}
},
{
"play": {
"url": "say: Thank you for using the live translation service. We will now end the translation session."
}
},
{
"live_translate": {
"action": "stop"
}
}
]
}
}
In the below example, the SWML script answers an incoming call and then starts recording the call.
The script then initiates a summarize
action to summarize the conversation. A webhook url
is provided to send the summarized conversation to a webhook, and the prompt
parameter is used to provide
instructions to the AI on how to summarize the conversation.
- YAML
- JSON
sections:
main:
- answer: {}
- record_call:
format: wav
stereo: 'true'
- live_translate:
action:
summarize:
webhook: 'https://example.com/webhook'
prompt: Summarize the key points of this conversation.
- connect:
from: '+1XXXXXXXXXX'
to: '+1XXXXXXXXXX'
{
"sections": {
"main": [
{
"answer": {}
},
{
"record_call": {
"format": "wav",
"stereo": "true"
}
},
{
"live_translate": {
"action": {
"summarize": {
"webhook": "https://example.com/webhook",
"prompt": "Summarize the key points of this conversation."
}
}
}
},
{
"connect": {
"from": "+1XXXXXXXXXX",
"to": "+1XXXXXXXXXX"
}
}
]
}
}
In the below example, the SWML script answers an incoming call and then starts recording the call.
Once the call is answered and recording has started, the call is then connected to a destination number.
After the call is connected, the script injects the message This is an injected message
into the conversation
for the remote-caller
to hear.
- YAML
- JSON
sections:
main:
- answer: {}
- record_call:
format: wav
stereo: 'true'
- connect:
from: '+1XXXXXXXXXX'
to: '+1XXXXXXXXXX'
- live_translate:
action:
inject:
message: This is an injected message.
direction: remote-caller
{
"sections": {
"main": [
{
"answer": {}
},
{
"record_call": {
"format": "wav",
"stereo": "true"
}
},
{
"connect": {
"from": "+1XXXXXXXXXX",
"to": "+1XXXXXXXXXX"
}
},
{
"live_translate": {
"action": {
"inject": {
"message": "This is an injected message.",
"direction": "remote-caller"
}
}
}
}
]
}
}