Audio (APL for Audio)
The Audio
component plays the provided audio file, such as an MP3 file.
Properties
The Audio
component has the base component properties and the following component-specific properties:
Property | Type | Default | Description |
---|---|---|---|
source |
String | "" | Specifies the URL for a remote audio file to play. |
source
Specifies the URL for a remote audio file to play. The URL must reference an audio file that meets the audio file requirements.
The source
property accepts a single URL to play a single audio file. To play a series of audio files, use a Sequencer
component with Audio
as its child component.
Alexa Skills Kit Sound Library support
The Audio
component supports the Alexa Skills Kit Sound Library for playing sound effects.
When you copy code for a sound from the sound library documentation, the code includes the full Speech Synthesis Markup Language (SSML) audio
tag. Extract the URL for the sound and assign it to the source
property of the Audio
component.
For example, copying the sound "nature_08" copies the following SSML code.
<audio src="soundbank://soundlibrary/water/nature/nature_08"/>
To use this in the Audio
component, assign the URL soundbank://soundlibrary/water/nature/nature_08
to the source
property as shown in this example.
{
"type": "Audio",
"source": "soundbank://soundlibrary/water/nature/nature_08"
}
The following example loads and plays a random sound from the sound library. Click the Load Audio button to play the clip the first time. Click the Reload button to load a different randomly-chosen sound. This example uses a hard-coded array of the sound library sounds in the data source.
Audio file support
Audio files used with the Audio
component must meet the following requirements.
Audio input formats
The Audio
component supports audio files in the following formats:
- aac
- mp3
- ogg
- opus
- wav
Audio input requirements
The audio file must meet the following requirements:
- Bit rate – The bit rate must be less than or equal to 1411.20 kbps.
- Sample rate – The sample rate must be less than or equal to 48kHz.
- File size – The file size of the audio clip can't be greater than 10 MB. If your file size is larger than 10 MB, consider editing the duration of the file or converting the file to another format, such as MP3 or Opus.
- Response length – The combined total time for the entire audio response generated from the components can't be more than 240 seconds.
URL requirements
Any URL provided in an APLA document, such as with the source
property in an Audio
component, must comply with the following:
- HTTPS – The audio file must be hosted at an Internet-accessible HTTPS endpoint.
- SSL certificates: – The domain hosting the audio file must present a valid, trusted SSL certificate. Avoid self-signed certificates. APL and Alexa Skills both use the same trusted list of CAs: List of trusted CAs from Mozilla
- CORS wildcards – Audio files must be CORS wildcard-enabled. The service must respond with the following header:
Access-Control-Allow-Origin: *
.
Supported channel layouts
The APL rendering engine supports the following channel layouts as input:
- mono
- stereo
Maximum concurrently mixing audio sources
You can mix no more than four audio sources together at any given moment.
Example
This example plays the rainforest sound stored at the specified URL. In this example, the audio file at the URL https://example.com/mySampleAudio/rainforestSoundEffect.mp3
must meet the requirements described in Audio file support
{
"type": "Audio",
"source": "https://example.com/mySampleAudio/rainforestSoundEffect.mp3"
}
This example plays the bird sound effects provided in the ASK sound library.
{
"type": "Audio",
"source": "soundbank://soundlibrary/animals/amzn_sfx_bird_forest_02"
}
Related topics
Last updated: Nov 28, 2023