*** id: 2735c0c1-8778-4c45-9441-45aaa28a3be9 title: play slug: /reference/play description: 'Play file(s), ringtones, speech or silence.' max-toc-depth: 3 ---------------- [statuscallbacks]: #statuscallbacks Play file(s), ringtones, speech or silence. ## **Properties** An object that accepts the following properties. Accepts either a single URL or multiple URLs. See [audio source](#audio-source) below. HTTP or HTTPS URL to deliver play status events. Learn more about [status callbacks][statuscallbacks]. ## **Audio source** The `play` object accepts one of the following properties to specify the audio source: A single [playable sound](#playable-sounds). Authentication can also be set in the url in the format of `username:password@url`. An array of [playable sounds](#playable-sounds). 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:]`. 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](#supported-ring-tones) 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:`. When using say, you can optionally set `say_voice`, `say_language` and `say_gender` in the [play or prompt properties](#properties). For the list of useable voices and languages, refer to the [supported voices and languages](#supported-voices-and-languages) section below. **Silence** To be silent for a certain duration, use `silence:`. 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](/docs/platform/voice/tts). ### 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**. | ## **StatusCallbacks** A POST request will be sent to `status_url` with a JSON payload like the following: The type of event. Always `calling.call.play` for this method. The channel for the event, includes the SWML session ID. Unix timestamp (float) when the event was generated. The project ID associated with the call. The Space ID associated with the call. An object containing playback-specific parameters. The call ID. The node handling the call. The control ID for this play operation. The current playback state. **Valid values:** `playing`, `paused`, `finished`, `error`. ### Raw JSON example ```json { "event_type": "calling.call.play", "event_channel": "swml:xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "timestamp": 1640000000.123, "project_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "space_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "params": { "call_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "node_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "control_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "state": "finished" } } ``` *** ## Examples ### Playing a single URL ```yaml version: 1.0.0 sections: main: - play: url: 'https://cdn.signalwire.com/swml/audio.mp3' ``` ```json { "version": "1.0.0", "sections": { "main": [ { "play": { "url": "https://cdn.signalwire.com/swml/audio.mp3" } } ] } } ``` ### Playing multiple URLs ```yaml 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' ``` ```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" ] } } ] } } ``` ### Playing multiple URLs with volume adjusted ```yaml 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' ``` ```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" ] } } ] } } ``` ### Specifying a voice to use for speaking **Globally** ```yaml 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?' ``` ```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?" } } ] } } ``` **For just one instance** ```yaml 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' ``` ```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" } } ] } } ```