Do you own a huge MP3 collection and you want to be able to listen it on your Alexa device? Are you an aspiring band and want to share your music with your fans for free? Or maybe you are just curious about how the Alexa Music Skill works.
In the following article I will try to explain how to build a simple music streaming service. You can find the complete source code here: https://github.com/andrei-ace/music-cloud
Your Amazon Alexa will be able to respond to commands like:
- “Alexa, play music on skill name.”
- “Alexa, play songs by artist name on skill name.”
- “Alexa, play the song name on skill name.”
The songs are from your own private collection, no need to buy them again or pay a subscription. Sure, you can connect and stream from your phone like with any other bluetooth speakers, but where is the fun in that? You will miss all the vocal commands you can use with Alexa Music Skill.
Prerequisites
- An Amazon developer account. Sign up is free.
- An AWS account. You host your skill code as an AWS Lambda function. Make sure this is an US account.
- A Dropbox Basic (free) account
Step 1 — install all the tools you need
- Install npm
- Install awscli
- Install ask cli and configure AWS credentials
- Generate an access token for your Dropbox account
Step 2 — DynamoDB
Go to AWS Console and create a new table named cloud-music with primary key id of type String and a secondary index named artist_id-id-index with primary key artist_id and a Sort key named id:
Provision read and write capacity to not exceed 5 read and 5 write units. This will keep you in the AWS free tier.
Go to IAM and add “dynamodb:*” permissions for the ask user.
Step 3 — upload your MP3 files to Dropbox and create your music catalog
$ git clone https://github.com/andrei-ace/music-cloud
$ cd music-cloud/dropbox-catalog/
$ npm install#edit .env.template with your Dropbox access token$ node index upload -d ./mp3/
$ node index.js catalog
You should see the list of your MP3 files:
The first command, for each MP3 file from the ./mp3/ directory it will:
- read the ID3 tags — please make sure each file has at least the artist and the title
- upload the file to Dropbox
- create a shareable link
- save the ID3 tags and the shareable link to the cloud-music table
The second command will create two files: artists.json and songs.json. These two files represent the catalogs which will be uploaded to Alexa and make it understand your music collection.
Step 4 — create your Alexa Skill
Go to Alexa Developer Console and create a new skill named “Music Cloud”. Choose the Music model and press Create skill button. Go to Build tab and press the Endpoint menu (left). Copy the skill id.
Step 5 — create your Lambda function
Go to AWS Lambda functions and create a new function named MusicCloudLambda as described here. Make sure your execution role contains permissions for accessing DynamoDB:
"Action": [
"dynamodb:BatchGetItem",
"dynamodb:PutItem",
"dynamodb:DeleteItem",
"dynamodb:GetItem",
"dynamodb:Scan",
"dynamodb:Query"
],
"Resource": "*"
It should look like this:
Copy the Lambda’s ARN (from the upper right corner: ARN — arn:aws:lambda:us-east-1:*:function:MusicCloudLambda) and go back to your Alexa Skill -> Build -> Endpoint and paste it into the Default endpoint field. Save.
Step 6 — deploy the skill code
Edit the .ask/config.template file with your skill id and lambda ARN. Rename the file to .ask/config. Deploy:
$ ask-cli deploy
Step 7 — upload the catalog files to Alexa
First, let’s create the artists catalog:
$ ask api create-catalog --catalog-type AMAZON.MusicGroup --catalog-title catalog-artists --catalog-usage AlexaMusic.Catalog.MusicGroup
Save the catalog id and associate it to your Alexa Skill.
$ ask api associate-catalog-with-skill -s YOUR-SKILL-ID-HERE -c YOUR-ARTISTS-CATALOG-ID-HERE
Replace the YOUR-SKILL-ID-HERE and YOUR-ARTISTS-CATALOG-ID-HERE with your skill and artist catalog id values.
Now let’s upload the artists.json file:
$ ask api upload-catalog -c YOUR-ARTISTS-CATALOG-ID-HERE -f ./artists.json
Save the upload id, you’ll need it later to check the status of the upload.
Build better voice apps. Get more articles & interviews from voice technology experts at voicetechpodcast.com
(Video) Making MusicPi: Amazon Echo music streaming box
Now do the same for the song catalog:
$ ask api create-catalog --catalog-type AMAZON.MusicRecording --catalog-title catalog-songs --catalog-usage AlexaMusic.Catalog.MusicRecording$ ask api associate-catalog-with-skill -s YOUR-SKILL-ID-HERE -c YOUR-SONGS-CATALOG-ID-HERE$ ask api upload-catalog -c YOUR-SONGS-CATALOG-ID-HERE -f ./songs.json
Save the upload id, you’ll need it later.
Step 8 — wait for the catalogs to be processed
Use the upload ids for both artist and song catalog to query for the upload status.
$ ask api get-catalog-upload -c YOUR-SONGS-CATALOG-ID-HERE -u YOUR-SONGS-UPLOAD-ID-HERE$ ask api get-catalog-upload -c YOUR-ARTISTS-CATALOG-ID-HERE -u YOUR-ARTISTS-UPLOAD-ID-HERE
Only after the ER_INGESTION step succeeds you can issue commands in the Test Console.
You can find more about catalogs here.
Step 9— test your Alexa Skill
Go to Alexa Developer Console -> Music Cloud skill -> Test tab and issue some test commands. If everything worked you should see something like this:
Don’t worry if you see the warning: “AudioPlayer is currently an unsupported namespace.” in the test console, that is normal. You will be able to listen to your songs on a real device like an Amazon Echo (or similar) that is linked with your developer account.
Catalog
There are 6 types of catalogs:
In our example we created catalogs just for the first two types — artists and songs.
An artist catalog looks like:
{...
"entities":[
{
"id":"g5NYvQMbvrqv76x+ItEErv5MJpE=",
"names":[
{
"language":"en",
"value":"SemMueL"
}
],
"popularity":{
"default":100
},
"lastUpdatedTime":"2019-10-08T14:51:23.326Z",
"deleted":false
}
]
}
A song catalog looks like:
{...
"entities":[
{
"id":"wuoQvgudnob9GJeKtqQxrAovVtY=",
"names":[
{
"language":"en",
"value":"Back in Time (Feat: Dylan Anthony Clark, Breanne Ponack)"
}
],
"popularity":{
"default":100
},
"lastUpdatedTime":"2019-10-08T14:51:18.849Z",
"artists":[
{
"id":"g5NYvQMbvrqv76x+ItEErv5MJpE=",
"names":[
{
"language":"en",
"value":"SemMueL"
}
]
}
],
"albums":[],
"deleted":false
}
]
}
Alexa Music Skill API
There are 4 types of requests that are mandatory for any music skill:
- GetPlayableContent — this request is sent when a user requests content to be played from your skill. If a user says: “Alexa, play It’s my life by Bon Jovi on music skill name” your skill will need to return the ContentId of that track as listed in your Amazon.MusicRecording catalog. If no entry can be found, an error message needs to be returned.
- Initiate — is sent when Alexa is ready for immediate playback of content obtained using a GetPlayableContent request. Alexa will send the ContentId and the skill responds with the stream URI.
- GetNextItem — is sent when a content queue was created, playback has started and Alexa needs the next item to buffer/enqueue for smooth song transition or if the user skipped the current item.
- GetPreviousItem — is sent when the content is playing and the user requests for the previous item.
GetPlayableContent
The skill needs to respond to three types of requests:
- “Alexa, play music on Music Cloud”
- “Alexa, play songs by artist name on Music Cloud”
- “Alexa, play song name on Music Cloud”
For the first type of request the selection criteria will look like:
"selectionCriteria": {
"attributes": [
{
"type": "MEDIA_TYPE",
"value": "TRACK"
}
]
}
The Music Cloud skill will return a random item from the DynamoDB table.
For the second type the selection criteria will look like:
"selectionCriteria": {
"attributes": [
{
"type": "ARTIST",
"entityId": "A2"
},
{
"type": "MEDIA_TYPE",
"value": "TRACK"
}
]
}
The Music Cloud skill will return a random song by the requested artist.
And lastly:
"selectionCriteria": {
"attributes": [
{
"type": "TRACK",
"entityId": "138545995"
},
{
"type": "MEDIA_TYPE",
"value": "TRACK"
}
]
}
The skill will return the exact song with the ContendId equal with the requested entityId.
Initiate
The important part from the Initiate request is:
"payload": {
"filters": {
"explicitLanguageAllowed": true
},
"contentId": "1021012f-12bb-4938-9723-067a4338b6d0",
"playbackModes": {
"shuffle": false,
"loop": false
}
}
The skill will need to respond with a playable stream:
"playbackMethod": {
"type": "ALEXA_AUDIO_PLAYER_QUEUE",
"id": "Queue-Id",
"rules": {
"feedback": {
"type": "PREFERENCE",
"enabled": true
}
},
"firstItem": {
"id": "1021012f-12bb-4938-9723-067a4338b6d0",
"playbackInfo": {
"type": "DEFAULT"
},
"metadata": {
"type": "TRACK",
"name": {
"speech": {
"type": "PLAIN_TEXT",
"text": "jeremy"
},
"display": "Jeremy"
},
"art": {}
},
"controls": [
{
"type": "COMMAND",
"name": "NEXT",
"enabled": true
}
],
"rules": {
"feedbackEnabled": true
},
"stream": {
"id": "STREAMID_92_14629004",
"uri": "https://cdn.example.com/api/1/a2f318467fbf2829996adc0880e0abd03d03b1ba6ac.mp3",
"offsetInMilliseconds": 0,
"validUntil": "2020-05-10T19:11:35Z"
},
"feedback": {
"type": "PREFERENCE",
"value": "POSITIVE"
}
}
}
GetNextItem
This will return a random song. The response data is similar with the Initiate response.
GetPreviousItem
This will return an error as the queue is not persisted by the skill at this point.
Some ideas for improvement:
- Add other types of catalogs (genre, playlists like: top 100 songs this week, etc)
- Improve the voice modelling by adding more and better data in the catalogs. An example would be to provide alternative names for artists, spell out numbers and non-alphabetic characters
- Track user playlists and song popularity
- Create a music recommendation system (maybe using TensorFlow)
andrei-ace/music-cloud
Install ask-cli and initialize it npm install -g ask-cli ask-cli init Edit .ask/congig.template with your skill id and…
github.com
FAQs
Can I play my own music library on Alexa? ›
To play your own MP3s (or music encoded in other formats, such as FLAC) on the Echo or other Alexa-compatible speakers, you can use Plex or My Media Server for Alexa, both of which allow you to stream songs you've stored on another device.
How do I create an Alexa music library? ›To do so, open the Amazon Music app on your phone and select My Music. Select Playlist > Create New Playlist > create a name for your playlist > tap Save. Then you can search for songs or albums to add to your playlist and tap the plus sign icon. When you're finished, tap Done.
How do I stream music on Alexa? ›You can also stream music from your mobile device to your Echo through a Bluetooth connection. With your phone or tablet nearby, say "Alexa, pair," and your Echo goes into pairing mode. Open the Bluetooth settings screen on your device and tap your Echo device (it should appear as Echo-XXX) when it shows up.
What music platform does Alexa use? ›By default, Alexa-enabled devices play music from the Amazon Music platform, but that's not the only available option. If you want to play music from other streaming services through one of the Amazon Echo devices, you can do it using your phone.
Can you put your own music on Amazon? ›Select “Upload” in the “Your Library” tab of the Amazon Music application. Then drag and drop music files from your computer into the app window. You can also click “Select Files” or “Select Folder” to browse your music.
Can I play my own mp3s on Amazon Music? ›"Uploading or importing your personal music to Amazon Music is no longer available", Amazon Music official stated.
Where does Alexa get her music from? ›Amazon Music is the default music service for Amazon Echo, so you shouldn't need to use the app at all. Once you've set up your Echo, Alexa should comply with your requests.
How do I set up Alexa music Unlimited? ›- Make sure you're within range of your Echo and say, "Alexa, sign up for Amazon Music Unlimited."
- From here, Alexa will guide you through the subscription process.
- Open the Alexa app .
- Open More and select Settings.
- Select Music & Podcasts, and then Link New Service.
- Select the music service provider and follow the on-screen instructions.
To play music on Alexa for free, you can link another device to your Amazon Echo. Another way is to listen to radio applications like TuneIn Radio or iHeartRadio. Then, you can also try free versions of music streaming services. Examples are Spotify Free, Free Amazon music, or Pandora.
Can you stream through Echo dot? ›
CNET How To - Stream any media to Amazon Echo - YouTube
Does Plex work with Alexa? ›Link Plex to Alexa
Open the the Alexa app on your mobile device or the Alexa web app. Navigate to Skills in the side bar menu. Search for Plex in the search field and select “Plex” from the results. Use the Enable button under the Plex logo.
Link Spotify to Alexa
Download and open the Alexa app. Tap the menu in the top-left. Tap Settings, then Music & Podcasts. Select Spotify, then Link account to Alexa.
Is there a monthly fee for Amazon Alexa? No, there's no monthly fee charged for Amazon Alexa. All you need is a stable WiFi connection to make your Echo work. However, having an Amazon Prime account gives you various benefits of using the Echo.
Is Amazon Music Unlimited free with Prime? ›Prime members can join Amazon Music Unlimited for only $8.99/month for a monthly subscription or $89/year for an annual subscription. Non-Prime customers pay $9.99/month.
How much music can I upload to Amazon? ›If you haven't used Amazon Cloud Player before, it's an online service where you can upload music and stream it via your internet browser. To get you started, Amazon gives you free cloud space for up to 250 songs if uploaded.
Can you upload music to Amazon Music for free? ›To get started, sign up for a free RouteNote account here, head to the Distribution tab and select Create New Release. Here you'll enter the metadata, and upload the tracks and artwork of your release. Be sure to select Amazon Music in the Manage Stores section.
Can I upload my own music to Spotify? ›You can upload local music from your computer onto Spotify by going through the Settings menu. Spotify Premium subscribers can listen to their uploaded music in the Spotify mobile app too. If you want to upload your music to Spotify so others can stream it, you'll need to go through a distribution service.
Can I transfer my YouTube music to Amazon Music? ›It takes just a few clicks! Start by selecting YouTube as a source music platform and then, select the next destination — Amazon Music streaming service. Once you pick your playlists and albums for the migration process, FYM will transfer them in a few minutes or less.
Can I upload my cds to Spotify? ›Thanks to Spotify's support for local files, you can rip and import any CD you own (in case it's not included in Spotify's cloud library). Even if the album is featured on Spotify, it's a good idea to keep a local library just in case you ever want to let your streaming subscription lapse.
Where can I post my songs for free? ›
- Free music distribution and free music promotion sites. Free streaming has become a very popular way to listen to and discover new music. ...
- Soundcloud. ...
- Jamendo. ...
- YouTube. ...
- Google Play. ...
- Bandcamp. ...
- Soundclick. ...
- Free Music Archive.
...
Availability.
Date | Country |
---|---|
December 7, 2021 | United Arab Emirates |
Nina Rolle is most likely behind Alexa
According to Wired, Stone's research for his book, "Amazon Unbound: Jeff Bezos and the Invention of a Global Empire," pointed to Boulder, Colorado, voice actress Nina Rolle.
Amazon's virtual assistant Alexa is Indian in ways you not even know. An India-born engineer, Rohit Prasad, has breathed life into Alexa, leading the technology side of the project almost from its inception five years ago. Prasad hails from Ranchi.
How much is Amazon Music Unlimited a month? ›UNLIMITED ACCESS TO 90 MILLION SONGS
Free for 30 days. Cancel anytime. Starts at $8.99/month after. New subscribers only.
...
Amazon Music Unlimited Specs.
Name | Value |
---|---|
Song Lyrics | Yes |
Better audio quality
Amazon Music Unlimited also offers five audio quality settings on both desktop and mobile apps, but it outperforms Spotify with its HD audio feature. Under its HD setting, you can get CD-quality audio with bitrates of up to 850 kbps.
How to set up your preferred music provider - YouTube
Can Alexa play music from other sources? ›No problem; your Echo can play your music from several other sources. Before you start listening to music from third-party services, you'll need to connect your accounts. To get everything set up, open up the Alexa app on your phone or visit the Alexa web interface.
Can DLNA play Alexa music? ›You can use the skill to play audio or video files on your DLNA devices, or the Echo devices themselves. If used with an Echo device, you can use all the usual playback commands Alexa supports for other audio/video services (pause, resume, shuffle, etc).
Is TuneIn free on Alexa? ›
TuneIn comes preloaded for free on all Alexa-enabled devices and offers listeners FM, AM, and internet radio and podcasts from around the world.
Is all music free on Alexa? ›Amazon Alexa now has free music for Echo owners who don't need Prime.
Can I broadcast through Alexa? ›Create your own announcement
To create an Alexa Announcement, simply say "Alexa, announce", and then say your announcement aloud. You can also say "Alexa, broadcast", and again, tack on your voice message at the end. So, for instance, you can say, "Alexa, broadcast 'the movie is starting.
If you use a smart TV, then you can hook your Alexa up directly to your TV. That way, you can use Alexa voice commands to open streaming apps, choose content, pause, adjust volume, and do about a thousand other things. Here's how you can connect Alexa to most smart TVs: Open the Alexa app on your phone or tablet.
Can you broadcast on Amazon Echo? ›Today Amazon announced a new feature called Alexa Announcements, which will let you simultaneously broadcast a voice message to every Echo in the house.
Can I turn Alexa into Jarvis? ›Say, “Alexa, introduce me to Jarvis.” If you haven't purchased the voice pack, proceed with the purchase. Choose whether you want explicit content or not. Alexa should confirm the voice change.
Is Plex free on Amazon? ›Plex is available on Amazon's new Fire TV! is a premium feature and requires a Plex Pass subscription.
Can Alexa Open third party apps? ›Amazon Alexa skill developers can now integrate their third-party apps into Alexa routines. This means greater variety of routine combinations as well as an increased user engagement and user experience.
Can Alexa play Spotify without phone? ›Amazon says the new Echo functionality includes Spotify Connect, which allows for a seamless transition between on-the-go and at-home listening. You can hand off whatever you're listening to from your mobile device to the Echo speaker, and it'll pick up right where you left off.
Is Spotify free with Amazon Prime? ›You won't be able to access your Spotify premium subscription for free with Amazon Prime. But users can listen to licensed music content in this popular application, which is played on the swedish music service. The number of tracks will be limited to two million, which is many times less than the Spotify library.
Is Spotify free on Alexa? ›
Use Spotify Free
Spotify on Alexa used to be limited to the paid-for platform, but now users of Spotify Free can also use their voice to summon music. There are limitations, however. You can only choose music from playlists, so you can't just pick and choose the music you want to hear on a whim.
Alexa is the virtual assistant, while Echo is the smart speaker device.
What is the difference between Alexa and echo dot? ›...
Echo vs. Echo Dot.
Amazon Echo | Amazon Echo Dot |
---|---|
It is a standalone smart device and a full-size smart speaker equipped with always-on Alexa. | The Dot is just as smart as the original Echo but works best with an external audio system attached. |
According to Florian Schaub, Assistant Professor in the University of Michigan School of Information, the microphones in these smart speakers “are always listening, but, by default, they are only listening for the 'wake word' or the activation keyword.” Since the whole purpose behind the device is to instantly respond ...
Can I transfer my Amazon Music to Spotify? ›It takes just a few clicks! Start by selecting Amazon Music as a source music platform and then, select the next destination — Spotify streaming service. Once you pick your playlists and albums for the migration process, FYM will transfer them in a few minutes or less.
Are all songs free on Amazon Prime? ›Want music without ads? Prime members have access to a catalog of more than 2 million songs, plus thousands of playlists and stations, all ad-free, at no additional cost to their Prime membership.
Why is Amazon Music charging me? ›Why Did My Amazon Music Single-Device Plan Cost Increase? You may have accidentally signed up for Amazon Music Unlimited on additional devices. Go to Your Amazon Music Settings to select a different plan or renewal option. To prevent future accidental purchases, Require a Voice Code for Purchases with Alexa.
Can Alexa play local music files? ›You should log in to Amazon Music Library with your Amazon account, click the 'Upload' button to drag and drop your local MP3 file or select the MP3 file for syncing. Once the local MP3 file is saved to your Amazon Cloud Library, you can directly say 'Alexa, play Amazon Music' to play your local MP3 on Alexa Echo.
Can Amazon Echo play my iTunes library? ›Streaming music and more
Once you have paired your iPhone with Alexa, you can open the Apple Music app and select the specific song or playlist that you want to stream. You should then hear this selection play through your Echo speaker. You can stream audio from iTunes, Apple Music, Podcasts, and even the Apple TV.
Here's what you need
An Apple Music subscription. If you're not a subscriber, you can join on your iPhone, iPad, or iPod touch, or on your Android device. An Amazon Echo, Amazon Fire TV, or Alexa-enabled Sonos speaker that you already set up with the Amazon Alexa app on your iOS or Android device.
Can Alexa play music from other sources? ›
No problem; your Echo can play your music from several other sources. Before you start listening to music from third-party services, you'll need to connect your accounts. To get everything set up, open up the Alexa app on your phone or visit the Alexa web interface.
Can Alexa play an entire album? ›You can get Alexa to play an entire album by using this command: “Alexa, play the album [name of the album] by [name of the artist].” If the album you are requesting Alexa to play is from a specific music service – like Spotify, for example – you will need to explicitly add 'from Spotify' at the end of your command.
Can Alexa play music without my phone? ›You can simply say, "Alexa, play my playlist on Amazon Music" or whatever music streaming service you use. You may need to link this service through your Amazon app if you haven't already done so. I hope this helps!
Is Amazon Music free with Prime? ›Amazon Music Prime is included with your Prime membership at no additional cost. It features 2 million songs and more than a thousand playlists and stations programmed by Amazon's music experts.
Can you stream Apple Music to echo dot? ›In addition to its low price-point, the Echo Dot is capable of playing music from Apple Music. Provided you have an active Apple Music subscription, it only takes a minute to set up your Echo Dot to play songs directly from Apple Music.
Can I transfer my Apple Music to Amazon? ›It takes just a few clicks! Start by selecting Apple Music as a source music platform and then, select the next destination — Amazon Music streaming service. Once you pick your playlists and albums for the migration process, FYM will transfer them in a few minutes or less.
Why can't I link Apple Music to Alexa? ›Check and Update Alexa and Apple Music App
If you're using an iOS device, ensure you update to the latest iOS version and check App Store for any updates to the Alexa app. And if you're using an Android device, check the Google Play Store to see if there are updates for the Amazon Alexa app and Apple Music app.
Apple Music vs Spotify: Songs and Audio Content
According to Spotify, it has "over 82 million tracks, including more than 4 million podcast titles." Meanwhile, Apple offers a more extensive catalog of 90 million songs for listening to.
Open the Apple Music app and play music. Find a song, album, or playlist that you want to play next. When you find something, touch and hold it, then choose when you want it to play: To play your selection right after the song that's playing, tap Play Next.
How do I get Alexa to play Apple Music everywhere? ›To play music on all your compatible Echo devices in the 'everywhere' group, just say “Alexa, play music everywhere.” For additional flexibility, you can set up additional Multi-room audio speaker groups via the Alexa app with a specific name, like 'downstairs' and then say “Alexa, play music downstairs.”
Is there a monthly charge for Alexa? ›
Is there a monthly fee for Amazon Alexa? No, there's no monthly fee charged for Amazon Alexa. All you need is a stable WiFi connection to make your Echo work. However, having an Amazon Prime account gives you various benefits of using the Echo.
Does Plex work with Alexa? ›Link Plex to Alexa
Open the the Alexa app on your mobile device or the Alexa web app. Navigate to Skills in the side bar menu. Search for Plex in the search field and select “Plex” from the results. Use the Enable button under the Plex logo.
Better audio quality
Amazon Music Unlimited also offers five audio quality settings on both desktop and mobile apps, but it outperforms Spotify with its HD audio feature. Under its HD setting, you can get CD-quality audio with bitrates of up to 850 kbps.