play
Play file(s), ringtones, speech or silence.
Properties
play
An object that accepts the following properties. Accepts either a single URL or multiple URLs. See audio source below.
play.status_url
HTTP or HTTPS URL to deliver play status events. Learn more about status callbacks.
Audio source
The play object accepts one of the following properties to specify the audio source:
Single URL (url)
Multiple URLs (urls)
play.url
A single playable sound. Authentication can also be set in the url in the format of username:password@url.
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 and HTTPS URLs are supported. Authentication can also be set in the url in the format of username:password@url.
Example: https://cdn.signalwire.com/swml/audio.mp3
Ring
To play the standard ringtone of a certain country, use ring:[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, use say:<text to speak>. When using say, you can optionally set say_voice, say_language and
say_gender in the play or prompt properties. 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, use silence:<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
StatusCallbacks
A POST request will be sent to status_url with a JSON payload like the following:
event_type
The type of event. Always calling.call.play for this method.
event_channel
The channel for the event, includes the SWML session ID.
timestamp
Unix timestamp (float) when the event was generated.
project_id
The project ID associated with the call.
space_id
The Space ID associated with the call.
params
An object containing playback-specific parameters.
params.call_id
The call ID.
params.node_id
The node handling the call.
params.control_id
The control ID for this play operation.
params.state
The current playback state. Valid values: playing, paused, finished, error.
Raw JSON example
Examples
Playing a single URL
Playing multiple URLs
Playing multiple URLs with volume adjusted
Specifying a voice to use for speaking
Globally
For just one instance