Paul

Unknown's avatar

I'm the Director of Developer Community at The Echo Nest, a research-focused music intelligence startup that provides music information services to developers and partners through a data mining and machine listening platform. I am especially interested in hybrid music recommenders and using visualizations to aid music discovery.

Writing an Echo Nest + Spotify App

Last week The Echo Nest and Spotify announced an integration of APIs making it easy for developers to write Spotify Apps that take advantage of the deep music intelligence offered by the Echo Nest. The integration is via Project Rosetta Stone (PRS).  PRS is an ID mapping layer in the API that allows developers to use the IDs from any supported music service with the Echo Nest API.   For instance, a developer can request via the Echo Nest playlist API a playlist seeded with a Spotify artist ID and receive Spotify track IDs in the results.

This morning I created a Spotify App that demonstrates how to use the Spotify and Echo Nest APIs together. The app is a simple playlister with the following functions:

  • Gets the artist for the currently playing song in Spotify
  • Creates an artist radio playlist based upon the now playing artist
  • Shows the playlist, allowing the user to listen to any of the playlist tracks
  • Allows the user to save the generated playlist as a Spotify playlist.
The app is functional, but not very pretty. Here’s a screenshot:

The entire app, including all of the HTML, CSS and JavaScript, is 150 lines long.I’ve made all the code available in the github repository SpotifyEchoNestPlaylistDemo.    Here are some of the salient bits. (apologies for the screenshots of code. WordPress.com has poor support for embedding sourcecode. I’ve been waiting for gist embeds for a year)

makePlaylistFromNowPlaying() – grabs the current track from spotify and fetches and displays the playlist from The Echo Nest.

fetchPlayst() – The bulk of the work is done in the fetchPlaylist method.  This method makes a jsonp call to the Echo Nest API to generate a playlist seeded with the Spotify artist.  The Spotify Artist ID needs to be massaged slightly. In the Echo Nest world Spotify artist IDs look like ‘spotify-WW:artist:12341234’ so we convert from the Spotify form to the Echo Nest form with the one liner:

  var artist_id = artist.uri.replace('spotify', 'spotify-WW');

Here’s the code:

The function createPlayButton creates a doc element with a clickable play image, that when clicked, calls the playSong method, which grabs the Spotify Track ID from the song and tells Spotify to play it:

Update: I was using a deprecated method of playing tracks. I’ve updated the code and example to show the preferred method (Thanks @mager).

When we make the playlist call we include a buckets parameter requesting that spotify IDs are returned in the returned tracks. We need to reverse the ID mapping to go from the Echo Nest form of the ID to the Spotify form like so:

Saving the playlist as a spotify playlist is a 3 line function:

Installing and running the app

To install the app, follow these steps:

  • make sure you have a Spotify Developer Account
  • Make a ‘playlister’ directory in your Spotify apps folder (On a mac this is in ~/Spotify/playlister)
  • Get the project files from github
  • Copy the project files into the ‘playlister’ directory. The files are:
    • index.html – the app (html and js)
    • manifest.json – describes your app to Spotify.  The most important bit is the ‘RequiredPermissions’ section that lists ‘http://*echonest.com’. Without this entry, your app won’t be able to talk to The Echo Nest.
    • js/jquery.min.js – jquery
    • styles.css – minimal css for the app
    • play.png – the image for the play button
    • icon.png – the icon for the app

To run the app type ‘spotify:app:playlister’ in the Spotify search bar. The app should appear in the main window.

Wrapping Up

Well, that’s it – a Spotify playlisting app that uses the Echo Nest playlist API to generate the playlist.  Of course, this is just the tip of the iceberg. With the Spotify/Echo Nest connection you can easily make apps that use all of the Echo Nest artist data:  artist news, reviews, blogs, images, bios etc,  as well as all of the detailed Echo Nest song data: tempo, energy, danceability, loudness, key, mode etc.  Spotify has created an awesome music app platform. With the Spotify/Echo Nest connection, this platform has just got more awesome.

Leave a comment

Is music getting more profane?

This post has profanity in it. If you don’t like profanity, skip this post and instead just look at this picture of a cat. Otherwise, scroll on down to read about the rise and fall of profanity in music.

 

Now, on to the profanity …

It seems that every year the amount of profanity in music has increased. Today it seems that every other pop song drops the f-bomb, from P!nk’s ‘Fucking Perfect’ to Cee Lo’s ‘Fuck You’.   I wondered if this apparent trend was real so I took a look at when certain obscene words started to show up in song titles to see if there are any obvious trends.  Here’s the data:

The word ‘fuck’ doesn’t appear in a song title until 1977 when the band ‘The Way’ released ‘Fucking Police’ .  This monumental song in music history seems to be lost to the Internet age.  The only evidence that this song ever existed is this MusicBrainz entry.   The second song with ‘fuck’ in the title, ‘To Fuck The Boss’ by Blowfly appeared in 1978.  This sophmore effort is preserved on Youtube:

[youtube http://www.youtube.com/watch?v=J3wGresI0S4]

The peak in usage of the word ‘fuck’ in song titles occurs in 2006 with 650 songs.  Since then, peak usage has dropped off substantially, 2011 saw about the same ‘fuck’ frequency as 1999.

Usage of the word ‘shit’ has a similar profile:

The first usage of the word ‘shit’ in a song title was in 1966 in the song ‘I feel like homemade shit’ by The Fugs, which appeared on The Fugs first album (originally titled The Village Fugs Sing Ballads of Contemporary Protest, Point of Views, and General Dissatisfaction).  Again the peak year of use is 2006 with 322 ‘shit’ songs that year.

Looking at these graphs, one would get the impression that use of profanity has grown substantially since the 70s and reached its peak a few years ago.   However, there’s more to the data than that.  Let’s look at a similar plot for a non-profane word:

This plot shows a very similar usage profile for the word ‘cat’,  with substantial growth in use from the 70s until 2006 when it starts to taper off.   (Yes, ‘cat’ was found in many songs before 1976, but I am not showing those in the plot). Why do ‘fuck’ and ‘cat’ have such similar profiles?  It is not because their usage frequency has increased, it is because the total number of songs released has been increasing year-over-year until 2006, after which the number of new releases per year has been dropping off.  We see more ‘fuck’s  and ‘cat’s in 2006 because there were more songs released in 2006 than any other year.  For a more accurate view we need to look at the relative usage changes.  This plot shows the usage of the word ‘fuck’ relative to the usage of other words in song titles.  Even when we look at the use of the word ‘fuck’ relative to other words there is a clear increasing trend.

 

 

Is music getting more profane? The answer is yes. The data show that the likelihood of a song with the word ‘fuck’ in the title has more than doubled since the 80s.  And it doesn’t look like this trend has reached its peak yet.  I think we shall continue to see a rise in use of language that gets a rise out of moms like Tipper Gore.

3 Comments

The Duke Listens! Archive

Before I joined the Echo Nest I worked in the research lab at Sun Microsystems. During my tenure at Sun I maintained a blog called ‘Duke Listens!’ where I wrote about things that I was interested in (mostly music recommendation, discovery, visualization, Music 2.0).   When Oracle bought Sun a few years back they shut down the blogs for ex-employees and Duke Listens! was no more.  However, a kind soul named John Henning spent quite a bit of time writing perl scripts to capture all the Duke Listens data. He stuck in on a CD and gave it to me.  It has been sitting on my computer for about a year. This weekend, while hanging out on the Music Hack Day IRC I wrote some python (thanks BeautifulSoup), reformatted the blog posts, created some indices and pushed out a static version of the blog.

You can now visit the Duke Listens! Archive and look through more than a 1,000 blog posts that chronicle the 5 years of Music 2.0 history (from 2004 to 2009). Some favorite posts:

,

Leave a comment

Waltzify – turn any 4/4 song into a waltz with Echo Nest remix

Tristan Jehan, one of the founders here at the Echo Nest,  has created a Python script that will take a 4/4 song and turn it into a waltz.  The script uses Echo Nest remix, a Python library that lets you algorithmically manipulate music.   Here’s an example of the output of the script when applied  to the song ‘Fame’:

Turning a 4/4 song into a 3/4 song while still keeping the song musical is no easy feat.  But Tristan’s algorithm does a pretty good job.  Here’s what he does:

  • Start with a 4/4 measure
  • Cut the 4/4 measure into 2 bars with 2 beats in each bar
  • Stretch the first beat of each bar by 100%
  • Adjust the tempo to a typical waltz tempo

Here’s a graphic that shows the progression:

 

Here are some more examples:

Tristan has made the waltzifier code available on github.  If you want to make your own waltzes, get  yourself an Echo Nest API key and grab Echo Nest remix and start enjoying the power of 3.

3 Comments

Slides for my Data Mining Music talk

I recently gave a talk on Data Mining Music at SXSW.  It was a standing room only session, with an enthusiastic audience that asked great questions.  It was a really fun time for me.   I’ve posted the slides to Slideshare, but be warned that there are no speaker notes so it may not always be clear what any particular slide is about.  There was lots of music in the talk, but unfortunately, it is not in the Slideshare PDF. The links below should flesh out most of the details and have some audio examples.

Data Mining Music

Related Links:

Thanks to everyone who attended.

, ,

Leave a comment

Data Mining Music at SXSW

If you happen to be in Austin this week for SXSW consider attending my talk called Data Mining Music.  It is all about the fun things you can discover about music when you have data about millions of songs and artists.

The talk is on Sunday, Marcy 11 at 5:00PM in the Rio Grande room of the Hilton Garden Inn.  All the details are here:  Data Mining Music

,

Leave a comment

Boil the Frog – the unreleased Spotify Version

Update – You are probably looking for this web-based version of Boil The Frog and the blog post about it.

Screenshot 1:2:13 5:54 AM-3

The rest of this article is about the unreleased Spotify Version of Boil the Frog.

I’m at Music Apps Hack Weekend doing my favorite thing: hacking on music. I’ve just finished my hack called Boil the Frog.  Boil the Frog  is a Spotify App that will create playlists that gradually take you from one music style to another.  It is like the proverbial story of the frog in the pot of water. If you heat the water gradually, the frog won’t notice and will happily sit in the pot until it becomes frog stew.  With Boil the Frog  you can do the same thing musically.  Create a playlist that gradually takes your pre-teen from Miley Cyrus to Miles Davis, or perhaps more perversely the Kenny G fan to Cannibal Corpse.

To build the app I built an artist similarity graph of 100,000 of the most popular artists. I use The Echo Nest artist similarity to connect each artist to its four nearest neighbors. To find the path between any two artists I use a bidirectional Dijkstra shortest path algorithm.  Most paths can be computed in less than 100ms.

The Spotify Apps API is the perfect hacking platform. You can build a Spotify app that has full access to the vast Spotify music catalog and artwork, along with access to the listener’s catalog.   Since the Spotify Apps run in an embedded browser all of your web app programming skills apply.  You can use jQuery, make calls to JSON APIs, use HTML 5 canvas. It is all there. Spotify has done a really good job putting together this platform.  The only downside is that, unlike the web, it is hard to actually release Spotify apps, but the Spotify team is working to make this easier.    I’d love to release Boil the Frog because it is really fun to make playlists that bring you from one music style to another. It is interesting to see what musical neighborhoods you wander through on your way.  For instance, I made a Kenny G to Cannibal Corpse playlist. To get there, the playlist brought me from easy listening, to movie soundtracks and then through video game soundtracks to get to the heavy metal world.  Cool stuff.  If you want to see a playlist between two artists let me  know in the comments and I’ll create and share the playlist with you.

I made a video of Boil the Frog in action.   Check it out:

[youtube http://youtu.be/Nj6JAxm9aPE]

Update: I’ve just pushed the client code out to github:  https://github.com/plamere/boilthefrog

, , ,

16 Comments

Hackathons are not nonsense

Dave Winer says that Hackathons are nonsense.  Specifically he says:

Hackathons are how marketing guys wish software were made.

However, to make good software, requires lots of thought, trial and error, evaluation, iteration, trying the ideas out on other users, learning, thinking, more trial and error, and on and on. At some point you say it ain’t perfect, but it’s useful, so let’s ship. That process, if the software is to be any good, doesn’t happen in 24 hours. Sometimes it takes years, if the idea is new enough.

Dave says that software is hard and you can’t you can’t expect to build shippable software in a day.  That’s certainly true, and if the goal of a hackathon was to get a bunch of developers together to build and ship commercial software in a day, I’d agree with him. But that’s not the goal of any of the hackathons I’ve attended.

I’ve participated in and/or helped organize perhaps a dozen Music Hack Days. At a Music Hack Day, people who are interested in music and technology get together for a weekend to learn about music tech and to build something with it.  The goal isn’t to ship a software product, it is to scratch that personal itch to do something cool with music.   The people who come to a Music Hack Day  are often not in the music tech space, but are interested in learning about  all the music APIs and tech available.  They come to learn and then use what they’ve learned to build something.  At the most recent Music Hack Day in San Francisco, 200 hackers built 60 hacks including new musical instruments, new music discovery tools, social music apps and music games.

Photo by Thomas Bonte

Music Hack Days are not nonsense. They are incredibly creative weekends that have resulted in a 1,000 or more really awesome music hacks.  Consider the hackathon to be the Haiku of programming. Instead of  17 syllables in 3 lines, a hacker has  24 hours. (Maybe we should call them Haikuthons;)   I think the 24 hour constraint contributes to the creativity of the event.

Here are some of my favorite hacks built at recent Music Hack Days. Plenty of whimsy but no nonsense here:

A hackathon is not nonsense.  It is not a time to build and ship a commercial product and no one who hacks at  a hackathon thinks that they are building anything more than a hack. That’s why hack is in the title. A hackathon is a time for like minded individuals to get together to learn something new, build something cool and show it off. In my experience, hackathons are incredibly creative time for learning and building something. What better way to spend a weekend.  Hackathons are awesome.

4 Comments

Billboard wins!

Yep, the numbers are in.  Out of 13 Grammy award, Billboard picked 7 correctly, while my web crawling approach picked 6.  Congrats to the a Billboard editorial team for winning (this round!).  Let me know where to send the milkshakes!

Here are the details. All the raw data is at Paul vs. Billboard.

 

Category Paul’s prediction Billboard’s prediction Actual Grammy Who was right?
Album Of The Year Adele Adele Adele Both
Record Of The Year Adele Adele Adele Both
Song of the Year Adele Bruno Mars Adele Paul
Best New Artist Bon Iver The Band Perry Bon Hiver Paul
Best Pop Solo Performance Adele Lady Gaga Adele Paul
Best Pop Duo/Group Performance Maroon 5 and Christina Aguilera Tony Bennett Tony Bennet Billboard
Best R&B Album Kelly Price Chris Brown Chris Brown Billboard
Best Country Album Jason Aldean Taylor Swift Lady Antebellum Neither
Best Dance/Electronica Album Cut/Copy Skrillex Skrillex Billboard
Best Rock Album Red Hot Chili Peppers Foo Fighters Foo Fighters Billboard
Best Alternative Music Album Bon Iver Bon Iver Bon Hiver Both
Best Latin Pop, Rock or Urban Album Calle 13 Calle 13 Maná Neither
Best Rap Album Kanye West & Jay-Z Nicki Minaj Kanye West Neither

Leave a comment

Paul vs. Billboard

Another weekend,  another Music Hack Day.  This weekend I’m at Tokbox headquarters in San Francisco at the 3rd annual Music Hack Day San Francisco, where 200 music hackers are building the future of music.

For my hack, I thought I would try to predict who would win the Grammy awards (the annual music awards presented by The Recording Academy) which is being held this evening.   To do this, I used the Echo Nest APIs to gather of lots of news and blog posts for each nominated artist. I then peered into the articles looking for mentions of the Grammy nominated items.  I tallied up the mentions and combined this with the overall artist hotttnesss to give me a ranked order of each nominated item, which I could then use to create my prediction.

Since Billboard has also made some Grammy predictions, I thought it’d be interesting to do a post-facto comparison on how well each of us predicts the winners – thus the hack title ‘Paul vs. Billboard’.

The hack is online here:  Paul vs. Billboard

Be sure to check out all of the other music hacks being created this weekend:

List of  Music Hackday San Francisco 2012 hacks

, ,

Leave a comment