Inspiration

Each night I’d repeat the same annoying process of unlock phone, connect to Bluetooth speaker, open my music app, find list of music etc. This was a process of around 5-6 steps, just to get music playing, and I didn’t like having the brightly lit screen of my phone while trying to drift off to sleep. I said to myself: “There has got to be an easier way.” I wanted to make a tool that would be useful and solve an actual problem in my life. At that point I knew what could solve it: A voice-controlled music player using a Raspberry Pi that plays music with just a simple Siri command.Yeah, instead of multiple steps we are now reduced to only one voice direction.

What it does

The Raspberry Pi Music Player is a voice-controlled music system that enables hands-free music playback through Siri integration. Here's what it can do:

Voice Activation: Play music by simply saying "Hey Siri, play my night music" Dual Music Sources:

Local playback from USB storage (10 pre-loaded songs) Cloud streaming from YouTube Music

Automatic Timer: Music stops automatically after a set duration (perfect for sleep listening) Hands-Free Operation: No need to touch your phone or computer Remote Control: Uses SSH commands triggered by iOS Shortcuts app

How we built it

Hardware Setup The physical setup consists of: Raspberry Pi 3 → Audio Cable → Amplifier → Wired Speaker Initial attempt: I tried using a Bluetooth speaker for wireless convenience, but the connection kept dropping. Solution: Switched to a wired setup for stable, reliable audio output. Software Implementation Step 1: Local Music Library Created a bash script for playing local music files: bash#!/bin/bash timeout 1800 cvlc --play-and-exit /home/pi/Music/*.mp3

Copied 10 favorite songs via USB Renamed files systematically: 01.mp3, 02.mp3, ..., 10.mp3 to avoid typos Used timeout command for automatic shutoff after 30 minutes (( 30\ times 60 = 1800 \ ) seconds)

Step 2: YouTube Music Integration Created a Python script (yt-music-tunes.py) for cloud streaming: python#!/usr/bin/env python3 import subprocess

Download audio from YouTube

url = "https://www.youtube.com/watch?v=VIDEO_ID" subprocess.run([ "yt-dlp", "-x", # Extract audio only "--audio-format", "mp3", "-o", "/tmp/%(title)s.%(ext)s", url ])

Play the downloaded audio

subprocess.run(["cvlc", "--play-and-exit", "/tmp/*.mp3"]) Step 3: Siri Integration Connected everything using iOS Shortcuts app:

Created shortcut with "Run Script Over SSH" action Entered Raspberry Pi connection details (IP address, username, password) Added remote command to execute Named the shortcut for Siri recognition

The SSH command structure: bashssh pi@192.168.x.x "timeout 1800 cvlc --play-and-exit /home/pi/Music/*.mp3" Technology Stack

Hardware: Raspberry Pi 3, wired speaker, amplifier Software: VLC media player, yt-dlp, Python 3, bash Networking: SSH (Secure Shell) Integration: iOS Shortcuts app, Siri voice commands

Challenges we ran into

  1. Bluetooth Connectivity Issues Problem: Bluetooth speaker randomly disconnected, even when appearing connected. Solution: Switched to wired connection. Sometimes the simpler solution is the better one—stability beats wireless convenience.

  2. Fixed Duration Settings Problem: Changing the timer duration required manually editing code. To change from 30 to 45 minutes, I had to:

Open the script Change 1800 to ( 45 \times 60 = 2700 ) Save and exit

Impact: Not convenient for varying listening times.

  1. YouTube Download Lag Problem: Streaming from YouTube causes 10-20 second startup delay while audio downloads. Trade-off: Accepted this as the cost of accessing unlimited music library vs. instant playback from local files.

  2. Manual URL Entry Per Song Problem: Each different song requires editing the Python script to change the URL. Current workaround: Maintain a note with favorite song URLs for quick copy-paste, but this defeats the "hands-free" goal.

  3. No Interrupt Capability Problem: Once music starts, it plays for the full timer duration. Cannot stop early via voice command. Impact: If volume is wrong or I change my mind, must physically access the Raspberry Pi to stop playback.

Accomplishments that we're proud of

  1. Successfully reduced complexity: Transformed 5-6 phone operations into a single voice command.
  2. Achieved true hands-free control: No need to touch phone or computer to play music.
  3. Built a hybrid system: Combined local storage (instant playback) with cloud streaming (unlimited variety).
  4. Implemented automatic timer: Perfect for nighttime listening without worrying about manually stopping music.
  5. Learned hardware integration: Successfully connected and configured audio hardware components.
  6. Mastered remote execution: Integrated multiple technologies (Raspberry Pi, iOS, SSH, Python, bash) into one cohesive system.
  7. Created a practical solution: The system works reliably and has become part of my daily routine.

The most rewarding moment was the first time I said "Hey Siri, play my night music" and heard the music start playing automatically from across the room. That moment validated all the troubleshooting and problem-solving that went into the project.

What we learned

Technical Skills

Hardware Integration: How to connect audio components and work with amplifiers Bash Scripting: Writing shell scripts for system automation Python Programming: Using subprocess module and working with command-line tools Network Communication: Setting up SSH connections and executing remote commands API Integration: Connecting iOS Shortcuts with Raspberry Pi via SSH

Problem-Solving Approaches

Flexibility is key: When Bluetooth failed, switching to wired was the right choice Simplicity over complexity: Sometimes the most straightforward solution (wired connection, numbered file names) works best Trade-offs are necessary: Accepted download lag for YouTube streaming in exchange for unlimited music access Iterative development: Started with local playback, then added streaming functionality

Project Management

Breaking down big problems: Divided the project into manageable steps (hardware → local playback → timer → Siri → streaming) Testing incrementally: Verified each component worked before adding the next feature Documentation matters: Keeping notes on commands and configurations saved time during troubleshooting

The most important lesson: Perfect is the enemy of good. My system works well despite its limitations, and those limitations are opportunities for future growth rather than reasons to abandon the project.

What's next for Raspberry Pi Music Player

  1. Dynamic Voice Timer Control Instead of editing code, implement Siri-based duration input:

User says: "Play music for 45 minutes" Shortcut extracts the number (45) Calculates seconds: ( 45 \times 60 = 2700 ) Passes as parameter to the script

  1. Interrupt Capability Create a "Stop music" Siri command: bashssh pi@192.168.x.x "killall vlc"
  2. Dynamic URL Input Siri shortcut prompts: "What's the YouTube URL?"

User provides URL via voice or paste Shortcut passes URL as parameter to Python script No more manual code editing

  1. Full Playlist Support Modify Python script to handle YouTube playlist URLs:

Automatically parse and download all songs in playlist Play in sequence Enable "shuffle" option via voice command

Advanced Features

  1. Web Interface Build a simple web dashboard for easier configuration:

Browse and select songs Adjust volume remotely View currently playing track Create and manage playlists

  1. Multi-User Support Different voice profiles for different users:

"Hey Siri, play my night music" vs. "Hey Siri, play Dad's music" Separate playlists and preferences per user

  1. Smart Features

Mood-based selection: "Play relaxing music" automatically selects appropriate songs Sleep detection: Gradually lower volume and fade out as user falls asleep Morning alarm: Gently wake up with gradually increasing music volume

  1. Integration with Music Services Expand beyond YouTube Music:

Spotify integration Apple Music support SoundCloud compatibility

  1. Enhanced Audio Control

Equalizer settings: "Increase bass" or "Reduce treble" Volume control: "Set volume to 50%" Skip functionality: "Next song" or "Previous song"

  1. Visual Feedback Add LED indicators to Raspberry Pi:

Playing: Green light Downloading: Yellow light Error: Red light

Long-term Vision Create a fully-featured smart speaker system that rivals commercial products like Amazon Echo or Google Home, but:

Open-source and customizable Privacy-focused (no cloud company listening) Expandable with additional features DIY-friendly for other makers

The ultimate goal is to make this project accessible to others who want to build their own voice-controlled music system, complete with documentation, tutorials, and pre-configured scripts.

Built With

Share this project:

Updates