harmony-cli
v1.1.0
Published
AI-powered music generation CLI tool using Google's Lyria RealTime for coding background music
Maintainers
Readme
🎵 H## Features
- 🎼 Real-time Music Generation: Uses Google's Lyria RealTime model for high-quality instrumental music
- ⏱️ 1-Minute Segments: Perfect length for immersive coding sessions
- 🔄 Parallel Processing: Generates next segment while current segment plays for seamless experience
- 🎵 Customizable Parameters: Set BPM, mood, and music themes
- 🎯 Coding-Focused: Designed specifically for background music while coding
- 🌈 Beautiful CLI Interface: Colorful and interactive command-line experience
- ⚡ No-Gap Playback: Seamless transitions between segments
- 🧹 Smart Memory Management: Automatic cleanup of old segments

An AI-powered music generation CLI tool that creates personalized instrumental music for coding sessions using Google's Gemini Lyria RealTime model.
Features
- 🎼 Real-time Music Generation: Uses Google's Lyria RealTime model for high-quality instrumental music
- 🎛️ Two Generation Modes:
- Interactive Mode: Generate 15-second segments on demand, perfect for focused work
- Continuous Mode: Auto-generate 30-second segments for uninterrupted listening
- 🔄 Parallel Processing: Generates next segment while current segment plays for seamless experience
- � Customizable Parameters: Set BPM, mood, and music themes
- � Coding-Focused: Designed specifically for background music while coding
- 🌈 Beautiful CLI Interface: Colorful and interactive command-line experience
- ⚡ No-Gap Playback: Seamless transitions between segments
- 🧹 Smart Memory Management: Automatic cleanup of old segments
Installation
- Clone or download this project
- Install dependencies:
npm install - Get your Gemini API key:
- Visit Google AI Studio
- Create or use an existing API key
- Make sure you have access to the Lyria RealTime model
Usage
Run the CLI tool:
npx harmony-cliOr if installed globally:
npm install -g .
harmony-cliInteractive Setup
The CLI will guide you through:
- API Key Input: Enter your Gemini API key
- Music Theme: Describe the type of music you want (e.g., "chill lo-fi hip hop", "ambient electronic", "peaceful piano")
- Tempo Selection: Choose BPM from predefined options (70-160 BPM)
- Mood Selection: Pick from various moods like Chill, Upbeat, Ambient, etc.
How It Works
🔄 Continuous Generation Workflow:
- Generate first 1-minute segment
- Play current segment + Generate next segment (in parallel)
- When both complete, seamlessly move to the new segment
- Repeat the cycle automatically
Perfect for coding because:
- ✅ 1-minute segments: Ideal length for immersive musical experience
- ✅ No interruptions: Generation happens while music plays
- ✅ No gaps: Seamless transitions between segments
- ✅ Continuous variety: New AI-generated music every minute
Example Prompts
Music Themes:
- "minimal techno for deep focus"
- "jazz fusion with smooth bass"
- "ambient electronic soundscape"
- "lo-fi hip hop with vinyl crackle"
- "classical piano with gentle strings"
- "synthwave retro vibes"
Available Moods:
- Chill
- Upbeat
- Ambient
- Energetic
- Peaceful
- Dreamy
- Focused
How It Works
- Connection: Establishes connection to Gemini Lyria RealTime via Python bridge
- Initial Generation: Creates first 30-second music segment
- Parallel Processing: While playing current segment, generates next segment in background
- Seamless Playback: Transitions between segments with no gaps
- Continuous Loop: Keeps generating and playing until user stops with Ctrl+C
- Smart Cleanup: Automatically removes old segments to save disk space
Parallel Generation Flow
🎼 Generate Segment 1 → 🎵 Play Segment 1
↓ (while playing)
🎼 Generate Segment 2 → 🎵 Play Segment 2
↓ (while playing)
🎼 Generate Segment 3...Technical Details
- Audio Format: 16-bit PCM, 48kHz, Stereo
- API: Google Gemini Lyria RealTime via WebSocket
- Latency: Low-latency real-time streaming
- Quality: High-fidelity instrumental music
- Watermarking: All generated audio includes identification watermarks
Configuration Options
The CLI automatically configures:
- BPM: 60-200 (user selectable)
- Temperature: 1.1 (creativity level)
- Density: 0.7 (musical complexity)
- Brightness: 0.6-0.8 (tonal quality)
- Guidance: 4.0 (prompt adherence)
- Mode: QUALITY (vs DIVERSITY)
Controls
While music is playing:
- Ctrl+C: Stop music and exit
- Music streams continuously with real-time generation
- Adaptive to coding rhythm and flow
Requirements
- Node.js 16+
- Valid Gemini API key with Lyria RealTime access
- Internet connection for real-time streaming
Notes
- Experimental Model: Lyria RealTime is currently an experimental model
- Instrumental Only: Generates instrumental music only
- Watermarked: All output follows Google's Responsible AI principles
- Real-time: Music generation adapts and continues based on your prompts
Troubleshooting
Connection Issues:
- Verify your Gemini API key is valid
- Check internet connection
- Ensure Lyria RealTime model access
Audio Issues:
- The CLI simulates audio streaming (actual implementation requires proper WebSocket setup)
- For real audio playback, additional system audio libraries may be needed
Development
This project demonstrates the structure for integrating with Gemini Lyria RealTime. The actual WebSocket implementation requires:
- Proper authentication with Gemini API
- WebSocket connection to the Lyria RealTime endpoint
- Audio buffer management for smooth playback
- Real-time prompt and configuration updates
License
MIT
Happy Coding with AI Music! 🎵
