Presentation video here: https://www.youtube.com/watch?v=goUzHd7cTuA&feature=youtu.be
When we talk about the Science of Music, determining useful information about raw audio is a very non-trivial task. Spotify (and the Echonest) has done a lot of impressive work in deriving data from audio such as beat and bar detection, timbre encoding, pitch data, and more. Spotify has made all of this information available for the public to use -- now it's up to you to figure out what you'd like to do with it!
The Spotify Web API provides a wealth of information on nearly all music within the Spotify catalog. From the API, you can get information on artists, tracks, albums, as well as both low and high-level audio analysis information. This talk will discuss what information is available to the public, show some examples of how to find and use it, and give a crash course in accessing this data from a Python application.
Designing IA for AI - Information Architecture Conference 2024
Audio Analysis with Spotify's Web API
1. Build rich applications with Spotify catalog data, profile and playlist
management, and more…
Spotify Web API
and Mobile SDKs
2. Today
Part I (now):
- An overview of the Spotify Web API and some
examples of how it's used
Part II (later):
- A deep dive into the Audio Analysis provided by
the Spotify Web API, how to interpret it, and a
demo showing how to use it for your own projects
4. Spotify Web API
Restful API
What can I get?
● Catalog metadata
● User profiles & playlists
● Audio features
● … and more
Access the API from
● Web Browser
● cURL
● API Console
● Your Code
It's FREE!!
5. What Information Can Be Retrieved?
Albums
Millions of albums with
● Cover art
● Data on available markets,
copyrights, genres, IDs, popularity
Artists
Millions of artists with
● Artists images
● Data on followers, genres, IDs, related
artists, popularity, top tracks
Tracks
30+ Million tracks
● 30 second previews (most tracks)
● Data on artists, available markets,
explicit lyrics, IDs, popularity
Playlists
2+ billion playlists with
● Full track listings
● Playlist images
● Data on followers
User Profiles
Spotify user profiles with
● Profile images
● Data on country, followers and
following, subscriptions
● Top Tracks and Artists
And more...
● Search across albums, artists, tracks
and playlists
● Top lists & new releases
● Browse by category
● Track recommendations
● Audio features
6. Audio Features of a track
Audio features available
https://developer.spotify.com/web-api/get-audio-features
Acousticness
Danceability
Energy
Instrumentalness
Key
Liveness
Loudness
Mode
Speechiness
Tempo
Time Signature
Valence
Get audio feature information about one or several tracks.
7. Audio Analysis of a track
Audio analysis available
https://developer.spotify.com/web-api/get-audio-analysis
http://docs.echonest.com.s3-website-us-east-1.amazonaws.com/_static/AnalyzeDocumentation.pdf
Bars
Beats
Sections
Segments
Pitches
Timbre
Tatums
Echoprint data
Deep and complex information about a track
8. What Data Can Be Managed?
Followers
Follow and unfollow...
● Artists
● Users
● Playlists
User’s Saved Tracks
In “Your Library”...
● Save tracks
● Remove tracks
● Check what’s saved
Playlists
● Create
● Rename
● Change public status
● Add, Remove & Replace Tracks
OAuth
The Web API uses the Spotify
Accounts Service at
https://accounts.spotify.com
to manage the secure login and
authentication of application users,
and asks for permission to manage
all sensitive user data.
10. Documentation and support for all APIs, SDKs
and widgets.
● Comprehensive user guides, reference manuals,
code examples & tutorials
● Full terms of use & FAQ
● Design resources & guides
● News and newsletter subscription service
https://developer.spotify.com
The Spotify Developer Website
11. ● Quickly test your API calls
● Full support for all parameters, field filters, and
request body data
● Sample data and default values
● Full support for OAuth tokens and scopes
● Full JSON responses with HTTP headers and
status codes
● cURL syntax and bookmarks
Interactive API Console
https://developer.spotify.com/web-api/console/
12. ● Exhibit your apps in our high-profile app
gallery
● See the apps others are building and get
ideas for your own apps
● Follow links to code repositories and
download the code
● Most apps are open source!
Spotify Developer Showcase
https://developer.spotify.com/showcase/
13. Make a playlists from a show
● Analyses set lists (from setlist.fm) and makes a
playlist
● Uses Spotify Web API playlist endpoint to
save playlists
● Uses Spotify Accounts Service to get user’s
permission to save playlist
Example: The Set Listener
https://github.com/plamere/SetListener
14. An entire client built on the Web API
Uses Spotify Web Api endpoints to retrieve
user’s playlists, tracks, personalisation, and
enable search
Example: Spotify on Playstation and TV
15. Spotify iOS & Android
SDKs
● Lightweight, native SDKs
● Full user authentication, audio playback
(premium users only)
● Complete API reference manual and
beginner's tutorial
● Code examples and wrappers
16. Makes it easy to add music streaming, user
authentication and other Spotify features to iOS apps.
The SDK consists of a small footprint binary library and a set of API header files. It
is packaged as an Xcode project and includes APIs for:
● User authentication
● Audio playback and stream management (for premium users only)
● Metadata (artist, album, track) lookup including artwork
● Playlist management
● User’s Your Music Library management
Registering your bundle ID
To communicate with Spotify you need to register your application’s bundle id
section in the Developer Portal. This value is used to authenticate your application
against Spotify client.
Spotify iOS SDK (beta)
Runkeeper uses the iOS SDK to connect
users to their Spotify playlists
https://developer.spotify.com/technologies/spotify-ios-sdk/
17. Makes it easy to add music streaming, user authentication
and other Spotify features to Android apps.
The SDK contains two small footprint binary libraries packaged as Android archives (AAR):
● Spotify Authentication Library. This library provides a way to obtain OAuth
access tokens that can subsequently be used to play music or used in calls to the
Spotify Web API.
● Spotify Player Library. This library contains classes for audio playback and
stream management (for premium users only). It takes care of all negotiation with
backend Spotify services, including digital rights management and decoding.
The Android SDK does not currently have functions for metadata lookup or playlist
management. For that, you need to use the Web API, with which you can communicate
after receiving an OAuth token from the SDK.
Android SDK (beta)
Shazam uses the Android SDK to
play full audio tracks
https://developer.spotify.com/technologies/spotify-android-sdk/
18. How do I build?
A streaming mobile app for
Spotify Premium
subscribers?
Android / iOS SDK
A data-rich non-streaming web
application for any Spotify user?
Web API
A simple Spotify-powered
webpage for my band, my
company, or myself?
Play Button
+
Follow Button
+
Web API
19. Spotify APIs / SDKs
Web API - https://developer.spotify.com/web-api/
Android SDK - https://developer.spotify.com/technologies/spotify-android-sdk/
iOS SDK - https://developer.spotify.com/technologies/spotify-ios-sdk/
HTML Widgets - https://developer.spotify.com/technologies/widgets/
24. Audio Features of a track
Audio features available
https://developer.spotify.com/web-api/get-audio-features
Acousticness
Danceability
Energy
Instrumentalness
Key
Liveness
Loudness
Mode
Speechiness
Tempo
Time Signature
Valence
Get audio feature information about one or several tracks.
27. Audio Analysis of a track
Audio analysis available
https://developer.spotify.com/web-api/get-audio-analysis
http://docs.echonest.com.s3-website-us-east-1.amazonaws.com/_static/AnalyzeDocumentation.pdf
Bars
Beats
Sections
Segments
Pitches
Timbre
Tatums
Echoprint data
Deep and complex information about a track
32. {
"start": 0.49557,
"duration": 0.49833,
"confidence": 0.978
},
{
"start": 0.99391,
"duration": 0.49336,
"confidence": 0.958
},
…
Bars, Beats, and Tatums
- Start time of the chunk
- Duration of the chunk
- Confidence of the chunk
(remember, these are
estimated!)
33. Beat: the basic time unit of a piece of music; for example, each tick of a
metronome
Beats
34. Tatum: the lowest regular pulse train that a listener intuitively infers from
the timing of perceived musical events (segments)
Tatums
* not used very often
35. Bar: a segment of time defined as a given number of beats. Bar offsets
also indicate downbeats, the first beat of the measure.
Bars
36. - Defined by large variations in
rhythm or timbre, e.g. chorus,
verse, bridge, guitar solo, etc
- Each section contains its own
descriptions of tempo, key,
mode, time_signature, and
loudness
- Disclaimer: They're not great
(IMO)
Sections
{
"start": 0,
"duration": 20.77904,
"confidence": 1,
"loudness": -22.169,
"tempo": 121.215,
"tempo_confidence": 0.9,
"key": 9,
"key_confidence": 0,
"mode": 0,
"mode_confidence": 0,
"time_signature": 4,
"time_signature_confidence": 1
},
37. {
"start": 0.73633,
"duration": 0.23265,
"confidence": 0.844,
"loudness_start": -40.031,
"loudness_max_time": 0.01147,
"loudness_max": -27.975,
"pitches": [
0.132,
0.106,
...
],
"timbre": [
26.205,
-254.481,
…
]
},
Segments
- A set of sound entities
(typically under a second)
each relatively uniform in
timbre and harmony
- Characterized by their
perceptual onsets and
duration in seconds, loudness
(dB), pitch and timbral
content
38. - Content is given by a “chroma” vector
- Corresponding to the 12 pitch classes C, C#, D to B, with values
ranging from 0 to 1 that describe the relative dominance of every
pitch in the chromatic scale
- a C Major chord would likely be represented by large values of C, E and G (i.e.
classes 0, 4, and 7)
- Vectors are normalized to 1 by their strongest dimension
- noisy sounds are likely represented by values that are all close to 1
- pure tones are described by one value at 1 (the pitch) and others near 0
Pitch
40. - The quality of a musical note or sound that distinguishes different
types of musical instruments, or voices
- Represented as a vector that includes 12 unbounded values
roughly centered around 0
- the first dimension represents the average loudness of the segment
- second emphasizes brightness
- third is more closely correlated to the flatness of a sound
- fourth to sounds with a stronger attack
- etc
- Best used in comparison with each other
Timbre
41. Timbre
50
ms
X ms PCA
460 floats / segment
12 floats / segment
dimensionality reduction
basis functions