Detecting Sadness Based on Your Spotify Listening History

Introducing Sad Boi Detector

Image for post
Image for post
“Sad Boi” logo by Joe Mortimer
A measure from 0.0 to 1.0 describing the musical positiveness conveyed by a track. Tracks with high valence sound more positive (e.g. happy, cheerful, euphoric), while tracks with low valence sound more negative (e.g. sad, depressed, angry).
Image for post
Image for post
const spotify = axios.create({
baseURL: 'https://api.spotify.com/v1/',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
}
}
let term = 'medium-term'spotify.get(`me/top/tracks?limit=50&time_range=${term}`)
.then(response => {
let ids = response.data.items.map(item => item.id).join(",")
})
spotify.get(`audio-features/?ids=${ids}`)
.then(response => {
let features = response.data.audio_features
let mean = _.meanBy(features, f => 1 - feature.valence)
let score = Math.round(mean * 100)
})

Written by

I develop websites for rock 'n' roll bands and get paid in sex and drugs. Previously Silva Artist Management, SoundCloud, and Songkick. Currently: Available

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store