Boriss Mejías and I presented a lightning talk at FOSDEM PGDay, last Friday. Below is the script, somewhat.
You know how you often fall back on one or a handful of tried and tested songs on an evening out? The ones you know the pitch is just perfect for your voice? Or, at least that’s what you think... But repetition is boring, and you want to shake things up a bit, show that you have range. What if Postgres could help you SELECT all the right bangers at your next karaoke party?
If experience makes one a subject matter expert, Boriss and I are definitely eligible to speak on the topic. The above picture is proof of one of many evenings where we sung our hearts out. Boriss is the actual musician, I just like karaoke, and the feeling when a whole room sings along to my emo rock picks.
How does Spotify/Deezer do the Discover Weekly? For people who don't use Spotify: Discover Weekly is a weekly list of 30 songs recommended must-listens, based on songs you've listened to and liked. Recommendation systems like it are everywhere, Amazon, GoodReads, you name it.
How accurate would a karaoke recommendation system need to be? We decided it’d probably be enough if it serves songs in the same genre and same “era”. Punk in the 90ies roughly follows a similar template, and we don't want to say "if you know one you know all”, but kinda.
Using a Kaggle dataset called “Top Hits Spotify from 2000-2019” we can serve up a set list for a contemporary evening, factoring in even more granularity than genre and release year, like…
- duration - Note of warning: most songs go on for longer than you think, not only the Queen classics. And there's only so long anyone should listen to a drunk performance of I Want You by The Beatles (7:47), ask me how I know. Eurovision songs are by design under 3 minutes long and in so in that way, and for other reasons too, pretty great for karaoke. Boriss reminded the audience that opinions of the co-speakers are their own.
- energy - Fancier karaoke parties might have a DJ curating what order songs will be played in, but you can be vigilant too! There's nothing like a balad ruining the vibes after a perfect streak of Sum41, Blink 182, Wheatus and Good Charlotte.
- explicit - With a group where you're not sure explicit language would be appreciated, make sure to filter that sh^t out.
- key - You don't need to understand anything about music to know that if a song is in a similar key, you'll probably be able to do a good job, provided you remember the melody.
A quick go at it would look like so:
CREATE TABLE karaoke (
artist text not null
, song text not null
, duration_ms int not null
, explicit boolean
, year text
, energy double precision
, key int
, instrumentalness double precision
, tempo double precision
, genre text
, PRIMARY KEY(artist, song)
);
Of course we only had 5 minutes, so we went for a pretty straightforward solution, yet one that can be more elaborate when introducing vectors and similarity search. If that sounds interesting, make sure to join Boriss’ PGDay Paris talk for an encore.
We also organized FOSDEM Karaoke, which took place February 1st, at DOA Karaoke. Proof of that evening will not be shared, but there will always be next year!
Top comments (0)