Tag: NAS

  • Dino’s Radio – turn a Raspberry Pi into your own radio station, with a DJ

    Your whole music library as a non-stop radio station – with a DJ – on a Raspberry Pi that was gathering dust.

    I had an old Raspberry Pi 2 in a drawer and a NAS full of music, so I turned them into my own Raspberry Pi radio station. Dino’s Radio plays the music on the NAS non-stop, crossfades between songs, evens out the volume between old and new recordings, and has a DJ who introduces the hits – “Here’s a UK number one from nineteen eighty-four…”. It streams in MP3, so it plays on our Amazon Echos as well as in a web browser or VLC. It’s free and open on GitHub, with a one-line install.

    Dino's Radio – Raspberry Pi radio station status page showing now playing, up next, station stats and the live log
    The status page – what’s on, what’s next, what the DJ will say, and the live log

    What it does

    • A hits-first mix. It looks up every song’s chart peak on Wikipedia. By default half the songs are UK or US top 10 hits, a third charted at 11–100, and the rest are album tracks. No song repeats within 3 days, and no artist within 15 songs.
    • A DJ. A natural British voice (Piper, running entirely on the Pi) talks over the start of a song with the music dipped underneath. Top 10 hits always get an introduction, other hits often, everything else now and then.
    • Voiced ahead of time. The radio picks the next six songs in advance and voices the DJ’s lines in the background, keeping every clip on the USB stick. That means even the slow, studio-quality voice works on a Raspberry Pi 2 – if a line isn’t ready in time, that song simply plays without a link.
    • The weather, once an hour. At a random time each hour the DJ reads the weather for your town – what it’s doing, the temperature, the wind and whether rain’s on the way – from Open-Meteo, with no account needed.
    • Never off air. If the NAS goes away (a reboot, a network blip), it switches to standby songs kept on a USB stick, and the DJ apologises: “Sorry, we’re having a little trouble reaching the record library… please hold.” When the music comes back: “And we’re back!”
    • Looks after itself. It checks for new or changed music every 15 minutes and starts by itself when the Pi powers up.
    • A status page you can open on any phone or PC at home, with a Listen button and the live log.
    • A nightly backup to a USB stick, so rebuilding the Pi puts everything back – even its fixed IP address – without reading the whole library again.

    What you need for a Raspberry Pi radio station

    • A Raspberry Pi 2 or newer on a network cable (the original Pi 1 is too slow).
    • Raspberry Pi OS Lite (Trixie) with SSH turned on.
    • Your music on a NAS or shared folder (MP3, FLAC, M4A, OGG, Opus or WAV). A read-only user for it is best.
    • A USB stick for backups and standby songs – 8 GB is plenty.

    Installing the Raspberry Pi radio station

    1. Put Raspberry Pi OS Lite on an SD card with Raspberry Pi Imager. In its settings set the hostname (I used dinoradio), turn on SSH and create a user.
    2. Plug the Pi into your router, plug in the USB stick, power it up, and connect with PuTTY (or any SSH app).
    3. Paste in these three lines:
    curl -L https://github.com/axelthefatcat/dinoradio/archive/refs/heads/main.tar.gz | tar xz
    cd dinoradio-main
    sudo bash install.sh

    The installer asks for the station name, your NAS address, the shared folder and a NAS user name and password, and which USB stick to use. Everything else is automatic – it takes 20–30 minutes on a Pi 2. At the end it shows your stream address (something like http://192.168.1.50:8000/radio-k3x9…) and the status page address. Try the stream in VLC straight away.

    The first time, it reads the whole library (up to an hour for about 12,000 songs). Chart positions take about a day to look up and volume levels a few days – they fill in quietly in the background, and the mix gets more “hits radio” as they do.

    Tip: give the Pi a fixed IP address so your players always find it. On Raspberry Pi OS Trixie the wired connection is usually called netplan-eth0:

    sudo nmcli connection modify netplan-eth0 ipv4.method manual ipv4.addresses 192.168.1.50/24 ipv4.gateway 192.168.1.1 ipv4.dns 192.168.1.1 && sudo nmcli connection up netplan-eth0

    The status page

    Open http://<your Pi>:8080 in any browser on your home network. It shows what’s playing and what’s next – including exactly what the DJ is going to say – chart badges, progress on the chart lookups and volume levelling, the last backup, a Listen button and the live log along the bottom. It updates every couple of seconds. Keep it on your home network: it has no login.

    Day to day

    CommandWhat it does
    dinoradio statusWhat’s on air, what’s next, and progress
    dinoradio skipSkip the current song
    dinoradio say "text"The DJ says something over an upcoming song
    dinoradio rescanLook for new music now
    dinoradio standby on / offTest standby mode
    dinoradio fill-standby 25Copy 25 more songs onto the USB stick for standby
    dinoradio backupBack up now
    dinoradio settingsChange the settings (mix, DJ, crossfade…), then restart
    dinoradio logWatch what it’s doing (Ctrl+C to stop)

    All the settings are in one file, /etc/dinoradio/settings.toml: the mix percentages, how chatty the DJ is, crossfade length, Christmas songs (December only by default), genres to leave out, and more.

    Updating

    Updates come from GitHub. Over SSH on the Pi, just type:

    update-radio

    It downloads the latest version and runs the installer, which recognises an existing station and doesn’t ask its questions again – your settings, stream address, chart positions, volume levels, play history, standby songs and the DJ’s voiced clips are all kept. To change the NAS details or the station name, run update-radio --reconfigure instead.

    Backup and restore

    Every night at 3am the radio backs up everything it has learnt to the USB stick, in a dinoradio folder: the track list, chart positions, volume levels and play history, the settings (including the stream address), the “please hold” messages and the Pi’s network settings. It keeps a week of backups. The standby songs already live on the stick. The NAS password isn’t backed up – you just type it again.

    • Back up now: dinoradio backup (the result shows in dinoradio status and on the status page).
    • Added the USB stick after installing? Run sudo bash install.sh --usb.
    • Rebuilding the Pi (new SD card, or a new Pi): plug the stick in and install as normal. The installer finds the latest backup and offers to restore it, then offers to put the fixed IP address back – your SSH session drops, so reconnect on the old address. The station carries on with the same stream address, so players and Alexa keep working, and there’s no full rescan.
    • Go back to last night’s backup on a working Pi: sudo bash install.sh --restore.

    If the stick isn’t plugged in, the nightly backup is skipped (the status says why) rather than quietly filling the SD card, and a few standby songs are kept on the SD card in case the stick is ever missing.

    Listening on Amazon Echo

    Echo speakers need a secure (HTTPS) address, so the stream goes through a reverse proxy – on a Synology NAS that’s in Control Panel › Login Portal › Advanced › Reverse Proxy – and a tiny Alexa skill plays it. I’ve written that part up separately: Play your own audio stream on Amazon Echo, with the full guide and skill code on GitHub. Point it at http://<your Pi>:8000 and use the stream address the installer showed you.

    If something’s not right

    What you seeWhat to do
    Status says STANDBYThe Pi can’t read the music. Check the NAS is on; it reconnects by itself (or run sudo mount -a).
    NOT STREAMINGIcecast has stopped: sudo systemctl restart icecast2 dinoradio.
    No DJdinoradio status says why – the voice is downloaded once during install, so it needs internet then.
    Chart lookups pausedWikipedia asked it to slow down. It waits (10 minutes up to 6 hours) and carries on by itself.

    How the Raspberry Pi radio station is built

    It’s Python on Raspberry Pi OS, with FFmpeg doing the audio (decoding, loudness measuring and the MP3 stream), NumPy mixing the crossfades and the DJ, Icecast serving the stream, SQLite remembering the library, and Piper for the DJ’s voice. Chart positions come from Wikipedia. I first built it on Liquidsoap, the usual radio-automation tool, but the version for the Pi 2’s 32-bit processor crashed on start-up – so it has its own small audio engine instead, which is light enough for a ten-year-old Pi.