Analyze the lyrics in your Spotify playlists using IBM Watson Tone Analytics.
App is currently hosted here.
Here's my blog post about the motivation and how this app is set up.
Prerequisites:
- Sign up for a Bluemix account
- Follow the steps for creating a Spotify Developer Account in this guide
- Create a Musixmatch Developer Account and get an App Secret
- In Bluemix, create an instance of the Tone Analytics service and an instance of Cloudant
You might also want to read my blog post on authenticating with spotify. That post guides you through the steps necessary to create a web app that follows Spotify's authentication workflow. Once you're good with that you can hop on back here to see how we use Spotify's APIs to pull in song data, get the lyrics for those songs, and then send those off to IBM Watson Tone Analytics.
npm i
phew! that was fun!
When running in Bluemix, Bluemix will set the credentials for the Tone Analytics
and Cloudant services as environment variables in your app. However, it's
annoying to set a bunch of environment variables when running locally, so the
code under the server
directory expects there to be ENV_VARS.json
and
VCAP_SERVICES.json
.
VCAP_SERVICES.json
is a literally a copy+paste of the VCAP_SERVICES object
under your app's "Environment Variables" tab in the Bluemix Dashboard.
ENV_VARS.json
is a custom file you'll need to create that looks like:
{
"CLIENT_ID": "YOUR_SPOTIFY_CLIENT_ID",
"CLIENT_SECRET": "YOUR_SPOTIFY_CLIENT_SECRET",
"REDIRECT_URI": "http://localhost:3000/callback",
"MUSIXMATCH_KEY": "YOUR_MUSIXMATCH_KEY"
}
npm run build
npm start
This will build the "production bundle" (minified javascript, no source maps,
etc) and place it under public/bundle.js
, and then start a server accessible
at localhost:3000
.
npm run dev
This will create a "dev bundle" (unminified javascript with source maps) for easier debugging while you're developing. It also uses some webpack magic for hot reloading.
- Provision an instance of the node.js runtime
- Bind the Tone Analytics service and Cloudant service to that runtime
- Add the
CLIENT_ID
,CLIENT_SECRET
,REDIRECT_URI
, andMUSIXMATCH_KEY
environment variables (same as above).
Once you're set up on that end all you'll need to do is
cf login
cf push <whatever_you_named_the_runtime>