OnyxMunk/MusicGen
๐ต VibeBlast - AI Music Generator
A cutting-edge text-to-music generation application with a "uniquely uncommon wildfire but harnessed into sharp black modern" aesthetic. Built with React, Vite, and powered by Hugging Face's MusicGen AI model.
โจ Features
๐จ Core Functionality
- Text-to-Music Generation: Transform text prompts into audio using state-of-the-art AI
- Real-time Audio Visualizer: Watch your music come alive with dynamic waveform visualization
- Persistent Song Library: All generated tracks are saved locally and survive page refreshes
- 8 Pre-built Vibe Suggestions: Quick-start generation with curated prompts (Cyberpunk, Lo-Fi, Phonk, Synthwave, etc.)
- User Audio Uploads: Upload your own audio samples to help improve the AI
- Interaction Tracking: Play, like, and regenerate actions are logged for continuous learning
๐ญ Design & UX
- Wildfire Theme: Animated wildfire background with sharp black modern aesthetic
- Glass-morphism UI: Premium translucent cards with backdrop blur effects
- Neon-red Accents: Eye-catching accent color throughout the interface
- Progress Indicators: Visual feedback during music generation
- Share Functionality: One-click sharing of prompts via URL
- Accessibility: ARIA labels, focus outlines, and keyboard navigation support
๐ Technical Highlights
- React 18 with Hooks and Context API for state management
- Vite for lightning-fast development and optimized builds
- Web Audio API for real-time audio analysis and visualization
- Express.js Backend for file uploads and interaction logging
- localStorage for client-side persistence
- Responsive Design with mobile-first approach
๐ฆ Project Structure
s```plaintext VibeBlastApp/ โโโ src/ โ โโโ components/ โ โ โโโ AudioVisualizer.jsx # Real-time waveform visualizer โ โ โโโ CreateView.jsx # Main music generation interface โ โ โโโ Header.jsx # Top navigation bar โ โ โโโ LibraryView.jsx # Rich library interface โ โ โโโ OverlayWrapper.jsx # Wildfire background wrapper โ โ โโโ Player.jsx # Audio playback controls โ โ โโโ ProgressBar.jsx # Generation progress indicator โ โ โโโ ShareButton.jsx # URL sharing functionality โ โ โโโ Sidebar.jsx # Navigation sidebar โ โ โโโ SongGrid.jsx # Song list display โ โ โโโ UserUpload.jsx # Audio sample upload โ โ โโโ VisualizerCard.jsx # Combined card with visualizer โ โ โโโ WildfireBackground.jsx # Animated wildfire effect โ โโโ context/ โ โ โโโ GeneratedSongsContext.jsx # Global state for generated songs โ โโโ hooks/ โ โ โโโ useAudioAnalyser.js # Web Audio API hook โ โ โโโ useInteractionTracker.js # Interaction logging hook โ โโโ utils/ โ โ โโโ musicGen.js # Hugging Face API integration โ โโโ index.css # Global styles with wildfire theme โ โโโ main.jsx # App entry point โ โโโ App.jsx # Main app component โโโ server/ โ โโโ index.js # Express backend server โ โโโ package.json # Backend dependencies โ โโโ uploads/ # User-uploaded audio storage โโโ public/ # Static assets โโโ .env.example # Environment variable template โโโ package.json # Frontend dependencies โโโ vite.config.js # Vite configuration
## ๐ ๏ธ Setup Instructions
### Prerequisites
- Node.js 16+ and npm
- A Hugging Face account and API token ([get one here](https://huggingface.co/settings/tokens))
### Installation
1. **Clone the repository** (or use your existing project):
cd /path/to/VibeBlastApp
2. **Install frontend dependencies**:
npm install
3. **Install backend dependencies**:
cd server npm install cd ..
4. **Configure environment variables**:
# Copy the example file cp .env.example .env
# Edit .env and add your Hugging Face token: # VITEHFTOKEN=hfYOURTOKEN_HERE
### Running the Application
You need to run **both** the frontend and backend servers:
#### Terminal 1: Frontend (Vite)
npm run dev
Runs on http://localhost:5174
#### Terminal 2: Backend (Express)
cd server npm run dev
Runs on http://localhost:4000
Then open your browser and navigate to: **<http://localhost:5174>**
## ๐ฎ Usage Guide
### Generating Music
1. Click **"Create"** in the sidebar
2. Either:
- Type a custom prompt describing your desired music, OR
- Click one of the 8 vibe suggestion chips
3. (Optional) Toggle **Instrumental** or **Auto-Lyrics** settings
4. Click **"Generate"** and wait ~30-60 seconds
5. Your generated track appears below with:
- Audio visualizer showing real-time waveform
- Play & Log button (sends interaction to backend)
- Download button for WAV file
- Share button to copy URL with prompt
### Uploading Audio Samples
1. Scroll to the bottom of the **Create** view
2. Click **"Choose File"** in the **"Upload Your Own Sample"** section
3. Select an audio file (WAV, MP3, etc.)
4. Click **"Upload"**
5. Your file is sent to the backend (`server/uploads/`) for future model training
### Viewing Your Library
- Generated songs persist across page refreshes (stored in `localStorage`)
- Click **"Library"** in the sidebar to view playlists, liked songs, and albums
- All cards use glass-morphism styling for a premium feel
## ๐งช API Integration
### Hugging Face MusicGen
The app uses the **facebook/musicgen-medium** model via the Hugging Face Inference API:
- **Endpoint**: `https://api-inference.huggingface.co/models/facebook/musicgen-medium`
- **Method**: POST
- **Headers**: `Authorization: Bearer YOUR_TOKEN`
- **Payload**: `{ "inputs": "your prompt here" }`
- **Response**: Audio blob (WAV format)
See `src/utils/musicGen.js` for the implementation.
### Backend Endpoints
#### `POST /api/upload`
- **Purpose**: Accept user-uploaded audio files
- **Body**: `multipart/form-data` with `audio` field
- **Response**: `{ "message": "Upload successful", "filename": "..." }`
#### `POST /api/track`
- **Purpose**: Log user interactions (play, like, regenerate)
- **Body**: `{ "songId": "...", "action": "play", "timestamp": 1234567890 }`
- **Response**: `{ "status": "logged" }`
## ๐จ Design System
### Color Palette
- **Background**: Sharp black (`#0a0a0a`, `#141414`)
- **Accent**: Neon red (`#ff0055`, `#ff1744`)
- **Fire Gradient**: Orange to red (`#ff6b35` โ `#ff0055`)
- **Text**: White with varying opacity
### Key CSS Variables
--color-black: #0a0a0a --color-black-dark: #050505 --color-neon-red: #ff0055 --color-neon-orange: #ff6b35 --color-fire-start: #ff6b35 --color-fire-end: #ff0055
### Animations
- **Wildfire**: 20s infinite background animation
- **Progress**: Linear progress bar during generation
- **Hover**: Scale transforms and color transitions
- **Spin**: Loading spinner for async operations
## ๐ Future Enhancements
### Roadmap
- [ ] Real model fine-tuning pipeline integration
- [ ] User authentication & cloud storage
- [ ] PWA capabilities (offline support, installable)
- [ ] Analytics dashboard for upload/play metrics
- [ ] Advanced audio processing (remix, extend, variations)
- [ ] Real-time collaborative generation
- [ ] Genre-specific model selection
- [ ] Lyric generation and display
### Model Improvement Strategy
The app is designed for **continuous learning**:
1. **Data Collection**: User uploads and interactions are logged
2. **Aggregation**: Backend stores audio files and usage metrics
3. **Fine-tuning**: Periodically retrain the model on collected data
4. **Deployment**: Update the inference endpoint with improved model
See the placeholder script at `scripts/fineTuneModel.js` for integration points.
## ๐ Environment Variables
| Variable | Description | Example |
|----------|-------------|---------|
| `VITE_HF_TOKEN` | Hugging Face API token | `hf_abcdef123456...` |
## ๐ค Contributing
This is a personal project, but contributions are welcome! Some areas that could use help:
- **Performance**: Optimize large audio file handling
- **UI/UX**: Additional visualizer modes (spectrum, bars, etc.)
- **Backend**: Switch from file storage to database (PostgreSQL, MongoDB)
- **Testing**: Unit tests for components and hooks
- **Documentation**: More detailed API docs and code comments
## ๐ License
This project is for educational and demonstration purposes.
## ๐ Credits
- **MusicGen Model**: Meta AI / Hugging Face
- **UI Inspiration**: Modern cyberpunk and glassmorphism design trends
- **Framework**: React team, Vite team
---
**Built with ๐ฅ by the VibeBlast team**
*"Wildfire aesthetics meet cutting-edge AI music generation"*
## ๐ Deployment to Hugging Face Spaces
This project is configured for deployment to Hugging Face Spaces using Docker.
1. **Create a new Space**: Select "Docker" as the SDK.
2. **Repository**: Connect this repository or push code to the Space's repo.
3. **Environment Variables**: Go to "Settings" -> "Variables and secrets" and add:
- `VITE_HF_TOKEN`: Your Hugging Face User Access Token (Secret).
4. **Port**: The Dockerfile automatically uses port `7860` as required by Spaces.
The Docker build process will:
- Build the React frontend
- Start the Express backend
- Serve the frontend via the backend on port 7860