play
Play file(s), ringtones, speech or silence.
Name | Type | Default | Description |
---|---|---|---|
play Required | object | - | An object that accepts the play parameters . |
play Parameters
Name | Type | Default | Description |
---|---|---|---|
urls (or url )Required | string | string[] | - | Either a playable sound, or an array of playable sounds Cannot pass both url and urls at the sametime. Authentication can also be set in the url in the format of username:password@url . |
volume Optional | number | 0 | Volume gain to apply to played URLs. Allowed values from -40.0 to 40.0 . |
say_voice Optional | string | Polly.Salli | Voice to use with say: for text to speech. |
say_language Optional | string | en-US | Language to use with say: for text to speech. |
say_gender Optional | string | female | Gender to use with say: for text to speech. |
Playable sounds
-
Audio file from a URL
To play an audio file from the web, simply list that audio's URL. Specified audio file should be accessible with an HTTP GET request.HTTP
andHTTPS
URLs are supported. Authentication can also be set in the url in the format ofusername:password@url
.Example:
https://cdn.signalwire.com/swml/audio.mp3
-
Ring
To play the standard ringtone of a certain country, usering:[duration:]<country code>
.The total duration can be specified in seconds as an optional second parameter. When left unspecified, it will ring just once. The country code must be specified. It has values like
us
for United States,it
for Italy. For the list of available country codes, refer to the supported ringtones section below. For example:ring:us
- ring with the US ringtone once
ring:3.2:uk
- ring with the UK ringtone for 3.2 seconds -
Speak using a TTS
To speak using a TTS, usesay:<text to speak>
. When using say, you can optionally setsay_voice
,say_language
andsay_gender
in the play or prompt params. For the list of useable voices and languages, refer to the supported voices and languages section below. -
Silence
To be silent for a certain duration, usesilence:<duration>
. The duration is in seconds.
Variables
Read by the method:
say_voice:
(in) - Optional voice to use for text to speech.say_language:
(in) - Optional language to use for text to speech.say_gender:
(in) - Optional gender to use for text to speech.
Possible Values for Voice, Language and Ringtone
Supported Voices and Languages
To learn more about the supported voices and languages, please visit the Supported Voices and Languages Documentation.
Supported Ring tones
Parameter | |
---|---|
urls.ring | Available values are the following ISO 3166-1 alpha-2 country codes: at, au, bg, br, be, ch, cl, cn, cz, de, dk, ee, es, fi, fr, gr, hu, il, in, it, lt, jp, mx, my, nl, no, nz, ph, pl, pt, ru, se, sg, th, uk, us, us-old, tw, ve, za. |
Examples
Playing a single URL
- YAML
- JSON
version: 1.0.0
sections:
main:
- play:
url: 'https://cdn.signalwire.com/swml/audio.mp3'
{
"version": "1.0.0",
"sections": {
"main": [
{
"play": {
"url": "https://cdn.signalwire.com/swml/audio.mp3"
}
}
]
}
}
Playing multiple URLs
- YAML
- JSON
version: 1.0.0
sections:
main:
- play:
urls:
- 'https://cdn.signalwire.com/swml/audio.mp3'
- 'say: this is something to say'
- 'silence: 3.0'
- 'ring:10.0:us'
{
"version": "1.0.0",
"sections": {
"main": [
{
"play": {
"urls": [
"https://cdn.signalwire.com/swml/audio.mp3",
"say: this is something to say",
"silence: 3.0",
"ring:10.0:us"
]
}
}
]
}
}
Playing multiple URLs with volume adjusted
- YAML
- JSON
version: 1.0.0
sections:
main:
- play:
volume: 20
urls:
- 'https://cdn.signalwire.com/swml/audio.mp3'
- 'say: this is something to say'
- 'silence: 3.0'
- 'ring:10.0:us'
{
"version": "1.0.0",
"sections": {
"main": [
{
"play": {
"volume": 20,
"urls": [
"https://cdn.signalwire.com/swml/audio.mp3",
"say: this is something to say",
"silence: 3.0",
"ring:10.0:us"
]
}
}
]
}
}
Specifying a voice to use for speaking
Globally
- YAML
- JSON
version: 1.0.0
sections:
main:
- set:
say_voice: gcloud.en-US-Neural2-A
- play:
url: 'say:Hi, do I sound different?'
- play:
url: 'say:I don''t, do I?'
{
"version": "1.0.0",
"sections": {
"main": [
{
"set": {
"say_voice": "gcloud.en-US-Neural2-A"
}
},
{
"play": {
"url": "say:Hi, do I sound different?"
}
},
{
"play": {
"url": "say:I don't, do I?"
}
}
]
}
}
For just one instance
- YAML
- JSON
version: 1.0.0
sections:
main:
- play:
url: 'say:Hi, do I sound different?'
say_voice: gcloud.en-US-Neural2-A
- play:
url: 'say:I was down with the flu'
{
"version": "1.0.0",
"sections": {
"main": [
{
"play": {
"url": "say:Hi, do I sound different?",
"say_voice": "gcloud.en-US-Neural2-A"
}
},
{
"play": {
"url": "say:I was down with the flu"
}
}
]
}
}