Henrify – DIY Spotify replacement stack
I love music, and for a long time I loved Spotify. It was one of the holy trinity of “life changing tech” for me, alongside Google Maps and Google Translate in terms of life-enrichment.
以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。
I love music, and for a long time I loved Spotify. It was one of the holy trinity of “life changing tech” for me, alongside Google Maps and Google Translate in terms of life-enrichment. But over time I felt the frustrations add up:
Thusly, over the course of the last couple of years I have been piecemeal building my own complete audio-serving stack, and I think it’s finally time:
So long, farewell
The henrify app
In this article I will try to present my Spotify replacement as a self-contained holistic design sketch, although in reality it accreted over time in a non-linear and complex fashion.
Here are some of the features of “henrify”, my home-grown alternative to spotify:
Self-hosted: All music files are stored in both high-quality and compressed formats on the hard drives duct-taped to the side of this box. The very-professional tunes Raspberry Pi setup. I know it looks goofy, but I kind of love it - and it has worked with 100% reliability for 4 years.
All the usual “Songs”, “Artists” etc views you’d expect from a music app, play queue management, offline tracks, etc
1280-dim embeddings are calculated for each track, allowing for fun ways to select a subset of my library to play and a “smart queue” feature.
Simple toggle to play music out of my home speakers instead of my phone, no bluetooth required. Nice for house parties.
Supports live radio (this is important to me, I listen to NTS Radio allatime) Live radio stream support
Customizable! I get to tweak small details like the caching algorithm used for prefetched songs, the visual styling, and even small things like the default options for various features.
Lassoing a mood on the 2D Vibe plot
Pinching & lassoing acoustic islands in Galaxy Mode
One of the things I actually did miss about big streaming platforms is being able to put on a “vibe” without having to hand-curate a playlist first. That’s probably a hot take - I think a lot of purists hate the “recommended” shuffle, but I was actually a big fan. I have never been a “playlist” kind of guy.
At first, you might think you can just filter by the Genre tags that the files contain. In practice, crowdsourced genre tags are kind of a mess for this:
So instead of trusting text tags, I use open-source audio models from UPF’s Essentia library to analyze the actual raw audio files directly. Sometimes I am quite skeptical of academic papers claiming to present pre-made classifiers/embedding models, but in this case I can attest that the Essentia models actually work! Huge news.
First, I wanted a 2D scatterplot where I can pick any two human-understandable axes from dropdowns and draw a freehand lasso loop with my finger to select a mood that trades off between the two:
The available 0-1 features I extract are:
All 5 numbers get post-normalized across my library into [0, 1] so they fill the square nicely. If I want “fast, miserable electronic music” or “slow, cheerful acoustic music”, I just pick the two axes, draw a circle on the density cloud, and hit shuffle.
Spotify used to actually expose their own internal values for these numbers in their awesome old developer API, but they totally nuked that a few years ago so now all of that data is inaccessible and we have recompute it ourselves. Thank god for academics & open science..
Next I wanted a cluster-view, so I could see how my songs related to each other. My first attempt at this kind of 2D “Galaxy” view just ran clustering on those 5 numbers above. It worked, technically, and it looked nice, but the groupings were musically terrible, since two songs can have the exact same BPM, energy, and valence and still sound nothing alike (say, an upbeat indie rock track vs. an upbeat synth-pop track).
To get groupings that actually sound right, I tapped into the penultimate layer of the discogs-effnet-bs64-1 model, which outputs a 1280-dimensional audio embedding alongside a 400-dimensional probability distribution over Discogs music styles for every 2-second window of the song.
Running spectral clustering on a k-NN graph of those high-dimensional audio vectors splits my library into ~14 distinct “islands” in a 2D archipelago, with hovering labels autogenerated from the top TF-IDF style activations of each island. Because it only looks at the raw audio (and ignores artist/album/genre tags completely), some really cool emergent behaviour falls out of it for free:
The Raspberry Pi is way too old to run TensorFlow models without catching fire, and my $4 DigitalOcean droplet (queequeg) only has 1 vCPU and 1GB of RAM.
To avoid OOM-killing the webserver while I’m listening to music during the day, feature extraction is queued up and handed to a nightly batch job:
This is broadly how the three devices communicate.
Most things I try and cache locally, just like Spotify. I keep a 1G LRU cache of music & metadata, and if you listen to a song for more than 15 seconds I prefetch the next 3 songs in the queue. Additionally, while I load the songs into the phone-local cache, I simultaneously fetch the first track via stream to minimize latency between “Play” and audio. It’s faster than Spotify, probably because I don’t have to worry about a CDN.
The music itself is stored very simply, because I wanted a reliable single source of truth which is easy to backup/mirror/manually inspect. All the raw audio files live on SSDs duct-taped next to the tunes Pi, in a simple folder structure (~/Music is symlinked to the SSD mount):
~/Music
- Artist
- AlbumName
- SongName
- cover.jpg
For example:
~/Music/ ├── 100 gecs │ └── 1000 gecs │ ├── 01 745 sticky.mp3 │ ├── 02 money machine.mp3 │ ├── 03 800db cloud.mp3 │ └── ... │ └── cover.jpg
These files are in the highest quality I have. I’m not a fussy guy, so it’s mostly 320kbps mp3, with a few FLAC files etc mixed in.
The entire music storage is exactly mirrored for a read-only fileserver that offers all of my music but transcoded to the smaller opus format. For example:
~/transcoded-Music/ ├── 100 gecs │ └── 1000 gecs │ ├── 01 745 sticky.mp3.opus │ ├── 02 money machine.mp3.opus │ └── 03 800db cloud.mp3.opus │ └── ...
Because the path is identical but with .opus appended, it all works very simply. The Droplet webserver queries the MPD server to get the canonical location of the “raw” audio file (which is actually inaccessible to the Henrify app for safety), appends .opus to the end of the canonical path, and then requests it from a lightweight read-only file server running in the transcoded-Music directory.
Originally I did on-the-fly opus transcoding, but to be honest the Pi can’t really keep up with it - hence the pre-transcoded file mirror. It wastes a bit of storage space I suppose, but that hasn’t been a problem for me yet.
Music metadata is automatically populated with beets, which also maintains its own parallel database. It’s really slick - you start off with a “mystery meat” random audio file, and beets will automatically find the best match on the MusicBrainz database and handle doing all the id3v2 tagging etc for you. In cases where there are multiple possible matches, beets gives you the top 10 best guesses and lets you decide. I find this to be a really smooth and reliable workflow. beets rocks!
One final note: Because I don’t actually play the music via MPD, the Henrify app is also responsible for manually incrementing the “playcount” etc metadata that MPD stores.
I won’t get into how I source the raw files. Suffice to say it’s a mix of manual additions (e.g. Bandcamp purchases, download codes that come with vinyls), and some automated sailing of the high seas.
Once you have an mp3 file sitting on the tunes Raspberry Pi, however that is achieved, the (fully automated) process goes like:
It usually takes about 5 seconds for steps 1-4 to run for a new addition to the music library.
For my migration off of Spotify, I ran a bulk import pipeline and asked Gemini 3.8-Flash to make the call for any ambiguous beets lookup conflicts. There were only a handful of them, and in all cases Gemini made a reasonable choice (I reviewed afterwards, of course).
Albums grid view
Play Queue & Now Playing sheet
Everything except the Android app was artisanally hand-coded by me over the last 2 years or so. But I never knew how to do anything related to front-end, so I never had a good control system. I used to use clunky mobile MPD clients, but I was never happy with them and so - to be honest - I used to just use Spotify anyway :-)
But now we live in an AI-slop world, I figured I could finally put the finishing piece of the puzzle in, and I got Gemini Argon to write the Android app for me. To be honest it did a spectacular job. I gave it very clear specifications, but I was still impressed by how few errors it made. Its aesthetic design was poor, but I was able to manually fix that once Gemini set up all the configuration options etc for me. Luckily I only wanted a fairly simple stripped-back UI, so I didn’t have too much to do.
Here are some screenshots of different parts of the app. Except the “Explore” tab, which is where I get new music from, and I prefer to keep sub rosa.
I love my new app, and unlike all of its previous iterations, this time I actually use it (!). I feel a bit awkward about presenting it to others - I feel like talking about your vibe-coded projects is a bit like bragging about having sex. It might have been awesome for you, but it’s a bit crass to make other people listen to your experiences. Hopefully you disagree and you enjoyed this article, though.
Of course, none of this would be remotely possible from scratch without decades of quietly brilliant open-source projects doing the real heavy lifting underneath:
I feel nothing but huge gratitude to the maintainers who built and documented these tools to empower people to DIY whatever they want.
I feel conflicted about AI in general, but one thing that I do think is awesome is how it democratizes the ability to be a hacker. 2 years ago, only a fullstack dev could have made Henrify. Now, a mere backend dev like me can make it.
I hope one day anybody, no matter how non-technical, can be empowered to make, own and customize their tools from scratch. Even if the implications of such a future for my career might be a little sketchy…
Does anyone even want this? It’s so bespoke to my own configuration, and the app is just vibecoded slop. You would be better off feeding this article to an agent and asking it to recreate my work.
Nevertheless, here is a repo (Antiochian/henrify) with the components of this app inside.
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。