spotify_dancer / README.md
CreaturesDigital's picture
v1.1.0: Auto-detect and fix ALSA configuration on startup
35af364
---
title: Spotify Dancer
emoji: 🎡
colorFrom: green
colorTo: gray
sdk: static
pinned: false
license: mit
short_description: Reachy Mini dances to your Spotify music!
tags:
- reachy_mini
- reachy_mini_python_app
- robot
- spotify
- dance
- music
---
# Spotify Dancer for Reachy Mini
Make your Reachy Mini dance to Spotify music! This app analyzes audio in real-time and generates expressive robot movements synchronized to the beat.
**Based on [DJ Reactor](https://huggingface.co/spaces/RyeCatcher/dj_reactor)** by RyeCatcher, enhanced with Spotify Connect integration and ALSA loopback for best audio detection quality.
## Features
- **Spotify Connect** - Reachy Mini appears as a speaker in your Spotify app
- **Real-time Beat Detection** - BPM estimation and beat tracking
- **Dance Styles** - Energetic, Groovy, Chill, and Hip-Hop modes
- **Stream Analysis** - Direct audio capture via ALSA loopback (best quality)
- **Web Control Panel** - Live visualizer with adjustable settings
- **Auto-Configuration** - Automatically detects and fixes ALSA audio settings
## Requirements
- **Reachy Mini WiFi version** (wireless connectivity required for Spotify Connect)
- Python 3.10+
- Spotify account (Free or Premium)
## Installation
### From Reachy Mini Dashboard
1. Go to `http://reachy-mini.local:8000`
2. Navigate to Apps
3. Search for "Spotify Dancer"
4. Click Install
### Manual Installation
```bash
pip install spotify_dancer
```
## Setup
### 1. Install Spotify Connect (raspotify)
```bash
curl -sL https://dtcooper.github.io/raspotify/install.sh | sh
# Configure
sudo nano /etc/raspotify/conf
# Set: LIBRESPOT_NAME="Reachy Mini"
# Set: LIBRESPOT_DEVICE=spotify
```
### 2. Enable ALSA Loopback (Recommended)
For best audio detection, use ALSA loopback:
```bash
sudo modprobe snd-aloop pcm_substreams=1
echo 'snd-aloop' | sudo tee /etc/modules-load.d/loopback.conf
```
See the [full ALSA setup guide](docs/spotify_setup.md) for multi-output configuration.
### 3. Fix Service Permissions
Create `/etc/systemd/system/raspotify.service.d/override.conf`:
```ini
[Service]
PrivateUsers=false
PrivateTmp=false
ProtectSystem=false
RemoveIPC=false
User=pollen
Group=audio
```
Then: `sudo systemctl daemon-reload && sudo systemctl restart raspotify`
## Usage
1. Start the app from Reachy Mini dashboard
2. Open control panel: `http://reachy-mini.local:7860`
3. Select **loopback_in** as Audio Input
4. Choose a dance style
5. Click **Start Dancing**
6. Play music on Spotify β†’ Select "Reachy Mini" as speaker
## Dance Styles
| Style | Best For | Movement |
|-------|----------|----------|
| Energetic | Rock, EDM | Strong head bobs, wide sway |
| Groovy | Pop, Funk | Classic nods, balanced movement |
| Chill | Jazz, Lo-Fi | Smooth tilts, gentle sway |
| Hip-Hop | Rap, R&B | Rhythmic nods, bass-driven |
## Audio Input Options
| Device | Quality | Notes |
|--------|---------|-------|
| `loopback_in` | ⭐ Best | Direct stream capture |
| `reachymini_audio_src` | Poor | Microphone with echo cancellation issues |
## Architecture
```
Spotify App β†’ raspotify β†’ ALSA multi-output
β”œβ”€β”€β†’ Speaker
└──→ Loopback β†’ Spotify Dancer β†’ Robot
```
## Troubleshooting
- **No loopback_in device**: Run `sudo modprobe snd-aloop` and restart the app
- **Poor detection**: Use loopback_in, increase sensitivity, turn up volume
- **Tracks skip**: Check ALSA config and IPC permissions (see setup guide)
- **ALSA errors after reboot**: The app auto-detects and fixes card numbers on startup. If issues persist, see the [setup guide](docs/spotify_setup.md)
## License
MIT License
## Credits
- **DJ Reactor** by [RyeCatcher](https://huggingface.co/spaces/RyeCatcher/dj_reactor) - Original dance movement system
- **Spotify Connect** via [raspotify](https://github.com/dtcooper/raspotify) (librespot wrapper)
- Built for the Reachy Mini community