Skip to content
Shaik-sufyaanPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎡 12Tree - AI-Powered Educational Song Generator for Kids

Transform any topic into gentle, educational songs for preschoolers (ages 3-5)

Built for EmoryHack 2024 | Powered by AI | Designed for Learning

FastAPI React MongoDB ElevenLabs Gemini


πŸ“‹ Table of Contents


🌟 Overview

12Tree is an AI-powered educational platform that generates custom songs for preschool children. Simply enter any topic (like "sun", "butterfly", or "friendship"), and our system creates:

  • βœ… Gentle, age-appropriate lyrics that teach concepts
  • βœ… Professional singing vocals via ElevenLabs AI
  • βœ… Custom background music perfectly synced
  • βœ… Beautiful karaoke-style player
  • βœ… Personal library to save favorites

Perfect for:

  • πŸ‘Ά Parents teaching their toddlers
  • πŸ‘¨β€πŸ« Preschool teachers creating lesson content
  • πŸŽ“ Educational content creators
  • 🏠 Homeschooling families

🎯 Key Features

🎨 For Users

  • Instant Song Generation: Create custom educational songs in 30-60 seconds
  • User Authentication: Secure sign-up/login with password hashing (bcrypt)
  • Personal Library: Save and organize your favorite songs
  • Beautiful UI: Colorful, kid-friendly interface with smooth animations
  • Karaoke Mode: Display all lyrics while song plays
  • Multi-User Support: Each user has their own private library

πŸ€– AI & Technology

  • Smart Lyrics: Gemini 2.5 Flash generates meaningful, educational content
  • Realistic Singing: ElevenLabs TTS with singing voice configuration
  • Custom Music: Randomly selected background tracks trimmed to vocal length
  • Audio Mixing: Professional-quality mixing with fade-outs
  • Caching System: Instant replay of previously generated songs
  • Async Processing: Real-time progress updates during generation

πŸŽ“ Educational Focus

  • Age-Appropriate: Gentle, soothing content for 3-5 year olds
  • Meaningful Lyrics: Each line teaches something about the topic
  • Natural Language: Simple words kids already know
  • Safe Content: No harsh words, pirate exclamations, or inappropriate themes
  • Clear Pronunciation: Optimized for learning and sing-along

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    12Tree Architecture                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  β”‚          β”‚       Backend Layer          β”‚
β”‚  React Frontend  │◄────────►│  FastAPI + Celery + Redis    β”‚
β”‚  (TypeScript)    β”‚  REST    β”‚                              β”‚
β”‚                  β”‚   API    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  - Login/Signup  β”‚          β”‚  β”‚  Core Services:        β”‚  β”‚
β”‚  - Music Mode    β”‚          β”‚  β”‚  - User Auth (bcrypt)  β”‚  β”‚
β”‚  - Library       β”‚          β”‚  β”‚  - Lyrics (Gemini)     β”‚  β”‚
β”‚  - Karaoke UI    β”‚          β”‚  β”‚  - Vocals (ElevenLabs) β”‚  β”‚
β”‚                  β”‚          β”‚  β”‚  - Audio Mixing        β”‚  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚  β”‚  - Background Music    β”‚  β”‚
                              β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                              β”‚                              β”‚
                              β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
                              β”‚  β”‚  Task Queue:           β”‚  β”‚
                              β”‚  β”‚  - Celery Workers      β”‚  β”‚
                              β”‚  β”‚  - Redis Broker        β”‚  β”‚
                              β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                           β”‚
                                           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Data & Storage                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  MongoDB Atlas                                              β”‚
β”‚  - Users (authentication)                                   β”‚
β”‚  - UserLibrary (saved songs per user)                       β”‚
β”‚  - SongCache (generated songs)                              β”‚
β”‚  - Jobs (task status)                                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    External APIs                            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  πŸ€– Gemini 2.5 Flash    β†’ Lyrics Generation                β”‚
β”‚  πŸŽ™οΈ  ElevenLabs TTS      β†’ Singing Voice Synthesis         β”‚
β”‚  🎡 Custom Music Files  β†’ Background Instrumentals          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”§ Tech Stack

Frontend

Technology Version Purpose
React 18.x UI framework
TypeScript 5.x Type safety
Vite 5.x Build tool & dev server
Tailwind CSS 3.x Styling
React Router 6.x Navigation

Backend

Technology Version Purpose
FastAPI 0.104+ REST API framework
Python 3.10+ Backend language
Celery 5.3+ Async task queue
Redis 5.0+ Message broker
Pydantic 2.5+ Data validation
bcrypt 4.1+ Password hashing

Database

Technology Version Purpose
MongoDB 6.0+ Primary database
Beanie 1.24+ Async ODM
Motor 3.3+ Async MongoDB driver

AI & Audio

Technology Version Purpose
Gemini API 2.5 Flash Lyrics generation
ElevenLabs 1.5+ TTS singing vocals
Bark Latest Fallback TTS
pydub 0.25+ Audio processing
librosa 0.10+ Audio analysis

πŸ”„ System Flow

Song Generation Pipeline

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Song Generation Flow                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

1. USER INPUT
   β”‚
   β”œβ”€β–Ί User enters topic (e.g., "butterfly")
   β”‚
   β–Ό

2. RHYME GENERATION
   β”‚
   β”œβ”€β–Ί pronouncing library finds kid-friendly rhyming words
   β”œβ”€β–Ί Filters out pirate/harsh words
   β”‚
   β–Ό

3. LYRICS CREATION (Gemini AI)
   β”‚
   β”œβ”€β–Ί Prompt: "Create gentle, educational song about [topic]"
   β”œβ”€β–Ί Requirements: 4-6 lines, age-appropriate, meaningful
   β”œβ”€β–Ί Safety filter: Remove any pirate exclamations
   β”œβ”€β–Ί Output: Clean, educational lyrics
   β”‚
   β–Ό

4. VOCAL SYNTHESIS (ElevenLabs)
   β”‚
   β”œβ”€β–Ί Format: "[singing gently and sweetly like a lullaby]"
   β”œβ”€β–Ί Settings: style=0.8, stability=0.3 for singing
   β”œβ”€β–Ί Voice: Child-friendly preset
   β”œβ”€β–Ί Output: High-quality singing vocals (.mp3)
   β”‚
   β–Ό

5. BACKGROUND MUSIC
   β”‚
   β”œβ”€β–Ί Select random track from 4 custom tracks
   β”œβ”€β–Ί Trim to exact vocal duration
   β”œβ”€β–Ί Apply 1-second fade-out
   β”‚
   β–Ό

6. AUDIO MIXING
   β”‚
   β”œβ”€β–Ί Load vocals and background
   β”œβ”€β–Ί Mix: vocals (100%) + instrumental (40%)
   β”œβ”€β–Ί Export final song (.mp3, 192kbps)
   β”‚
   β–Ό

7. METADATA & CACHING
   β”‚
   β”œβ”€β–Ί Calculate BPM, duration
   β”œβ”€β–Ί Generate timings for karaoke
   β”œβ”€β–Ί Save to MongoDB SongCache
   β”œβ”€β–Ί Return to user (instant on replay!)
   β”‚
   β–Ό

8. USER LIBRARY
   β”‚
   └─► User can save to personal library
       └─► Stored in MongoDB with user_id

User Authentication Flow

SIGNUP                           LOGIN
   β”‚                               β”‚
   β”œβ”€β–Ί Username + Email + Password β”‚
   β”œβ”€β–Ί Validate (unique, length)   β”œβ”€β–Ί Username + Password
   β”œβ”€β–Ί Hash password (bcrypt)      β”œβ”€β–Ί Find user in MongoDB
   β”œβ”€β–Ί Save to MongoDB Users       β”œβ”€β–Ί Verify password
   β”œβ”€β–Ί Auto-login                  β”œβ”€β–Ί Update last_login
   β”‚                               β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
                    β–Ό
           Store in localStorage
                    β”‚
                    β–Ό
          User can access library

πŸ“ Project Structure

EmoryHack/
β”‚
β”œβ”€β”€ Frontend/                          # React Frontend
β”‚   └── 12Tree-frontend/
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ api/
β”‚       β”‚   β”‚   └── index.ts          # API client, auth functions
β”‚       β”‚   β”œβ”€β”€ components/
β”‚       β”‚   β”‚   β”œβ”€β”€ FullScreenPlayer.tsx    # Karaoke player
β”‚       β”‚   β”‚   β”œβ”€β”€ MusicMode.tsx           # Song generation UI
β”‚       β”‚   β”‚   β”œβ”€β”€ LibrarySongItem.tsx     # Library items
β”‚       β”‚   β”‚   └── Toast.tsx               # Notifications
β”‚       β”‚   β”œβ”€β”€ pages/
β”‚       β”‚   β”‚   β”œβ”€β”€ Login.tsx               # Login page
β”‚       β”‚   β”‚   β”œβ”€β”€ Signup.tsx              # Signup page
β”‚       β”‚   β”‚   β”œβ”€β”€ Library.tsx             # User's saved songs
β”‚       β”‚   β”‚   └── Learn.tsx               # Main dashboard
β”‚       β”‚   β”œβ”€β”€ context/
β”‚       β”‚   β”‚   └── AppContext.tsx          # Global state (user)
β”‚       β”‚   β”œβ”€β”€ hooks/
β”‚       β”‚   β”‚   └── useSongs.ts             # Fetch user library
β”‚       β”‚   └── main.tsx                    # App entry point
β”‚       β”œβ”€β”€ package.json
β”‚       └── vite.config.ts
β”‚
β”œβ”€β”€ app/                               # FastAPI Backend
β”‚   β”œβ”€β”€ main.py                        # FastAPI application
β”‚   β”œβ”€β”€ config.py                      # Settings (env variables)
β”‚   β”œβ”€β”€ database.py                    # MongoDB connection
β”‚   β”œβ”€β”€ models.py                      # Beanie models
β”‚   β”‚                                  #  - User
β”‚   β”‚                                  #  - Job
β”‚   β”‚                                  #  - SongCache
β”‚   β”‚                                  #  - UserLibrary
β”‚   β”œβ”€β”€ tasks.py                       # Celery background tasks
β”‚   └── services/
β”‚       β”œβ”€β”€ rhyme_service.py           # Rhyme generation
β”‚       β”œβ”€β”€ lyrics_service.py          # Gemini lyrics AI
β”‚       β”œβ”€β”€ vocal_service.py           # ElevenLabs/Bark TTS
β”‚       β”œβ”€β”€ background_music_service.py # Music track manager
β”‚       β”œβ”€β”€ beat_generator.py          # Fallback beat generator
β”‚       └── audio_service.py           # Audio mixing utilities
β”‚
β”œβ”€β”€ background_music/                  # Custom Music Tracks
β”‚   β”œβ”€β”€ track1.mp3
β”‚   β”œβ”€β”€ track2.mp3
β”‚   β”œβ”€β”€ track3.mp3
β”‚   β”œβ”€β”€ track4.mp3
β”‚   └── README.md
β”‚
β”œβ”€β”€ outputs/                           # Generated songs
β”œβ”€β”€ temp/                              # Temporary files
β”œβ”€β”€ Docs/                              # Documentation
β”‚   β”œβ”€β”€ QUICKSTART.md
β”‚   β”œβ”€β”€ CUSTOM_MUSIC_SETUP.md
β”‚   β”œβ”€β”€ OPTIMIZATION_GUIDE.md
β”‚   └── ...
β”‚
β”œβ”€β”€ requirements.txt                   # Python dependencies
β”œβ”€β”€ .env                               # Environment variables
β”œβ”€β”€ .env.example                       # Template
└── README.md                          # This file

πŸš€ Quick Start

Prerequisites

Ensure you have the following installed:

  • Node.js 18+ and npm
  • Python 3.10+
  • MongoDB (local or Atlas)
  • Redis (local or cloud)

1. Clone Repository

git clone <your-repo-url>
cd EmoryHack

2. Backend Setup

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Configure environment variables
cp .env.example .env
nano .env  # Add your API keys

Required Environment Variables:

# .env file
GEMINI_API_KEY=your_gemini_api_key_here
ELEVENLABS_API_KEY=your_elevenlabs_api_key_here
MONGODB_URL=your_mongodb_connection_string
REDIS_URL=redis://localhost:6379/0

# Optional
USE_CUSTOM_BACKGROUND_MUSIC=True
TTS_PROVIDER=elevenlabs

3. Frontend Setup

cd Frontend/12Tree-frontend

# Install dependencies
npm install

# Configure API URL (if needed)
echo "VITE_API_URL=http://localhost:8000" > .env

# Build for production (optional)
npm run build

4. Add Background Music (Optional)

Place your 4 MP3 tracks in background_music/:

background_music/
β”œβ”€β”€ track1.mp3
β”œβ”€β”€ track2.mp3
β”œβ”€β”€ track3.mp3
└── track4.mp3

5. Start Services

Terminal 1 - Redis:

redis-server

Terminal 2 - MongoDB:

mongod  # If running locally
# Or use MongoDB Atlas (cloud)

Terminal 3 - Celery Worker:

cd EmoryHack
source venv/bin/activate
celery -A app.tasks worker --loglevel=info

Terminal 4 - FastAPI Backend:

cd EmoryHack
source venv/bin/activate
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

Terminal 5 - React Frontend:

cd Frontend/12Tree-frontend
npm run dev

6. Access Application


πŸ“– Detailed Setup

MongoDB Setup

Option 1: Local MongoDB

# Install MongoDB
# Ubuntu/Debian:
sudo apt-get install mongodb

# macOS:
brew install mongodb-community

# Start MongoDB
mongod

Option 2: MongoDB Atlas (Recommended)

  1. Go to https://www.mongodb.com/cloud/atlas
  2. Create free M0 cluster
  3. Get connection string
  4. Add to .env: MONGODB_URL=mongodb+srv://...

Redis Setup

Option 1: Local Redis

# Ubuntu/Debian:
sudo apt-get install redis-server

# macOS:
brew install redis

# Start Redis
redis-server

Option 2: Redis Cloud (Recommended)

  1. Go to https://redis.com/try-free/
  2. Create free 30MB database
  3. Get connection URL
  4. Add to .env: REDIS_URL=redis://...

Get API Keys

Gemini API (Free):

  1. Visit https://ai.google.dev/
  2. Click "Get API Key"
  3. Create new key
  4. Add to .env: GEMINI_API_KEY=...

ElevenLabs API:

  1. Visit https://elevenlabs.io/
  2. Sign up for free account (10,000 characters/month)
  3. Get API key from settings
  4. Add to .env: ELEVENLABS_API_KEY=...

πŸ“š API Documentation

Authentication Endpoints

Sign Up

POST /api/auth/signup
Content-Type: application/json

{
  "username": "john_doe",
  "email": "[email protected]",
  "password": "secure123"
}

Response:

{
  "message": "Account created successfully",
  "user": {
    "username": "john_doe",
    "email": "[email protected]"
  }
}

Login

POST /api/auth/login
Content-Type: application/json

{
  "username": "john_doe",
  "password": "secure123"
}

Response:

{
  "message": "Login successful",
  "user": {
    "username": "john_doe",
    "email": "[email protected]"
  }
}

Song Generation Endpoints

Generate Song

POST /api/generate
Content-Type: application/json

{
  "word": "butterfly"
}

Response:

{
  "job_id": "abc-123-def-456",
  "status": "processing",
  "progress": 0
}

Get Job Status

GET /api/jobs/{job_id}

Response (Processing):

{
  "job_id": "abc-123",
  "status": "processing",
  "progress": 45,
  "error": null
}

Response (Completed):

{
  "job_id": "abc-123",
  "status": "completed",
  "progress": 100,
  "result": {
    "word": "butterfly",
    "lyrics": "The butterfly is soft and light\nIt dances in the air...",
    "audio_url": "/outputs/song_abc123.mp3",
    "timings": [
      {"word": "The", "start": 0.0, "end": 0.2},
      {"word": "butterfly", "start": 0.2, "end": 0.8}
    ],
    "duration": 25.5,
    "bpm": 95.0
  }
}

Library Endpoints

Save Song to Library

POST /api/library/songs
Content-Type: application/json

{
  "userId": "john_doe",
  "title": "The Butterfly Song",
  "lyrics": "...",
  "audioUrl": "/outputs/song_abc.mp3",
  "timings": [...],
  "duration": 25.5,
  "bpm": 95.0
}

Get User's Library

GET /api/library/songs?user_id=john_doe

Response:

{
  "songs": [
    {
      "id": "507f1f77bcf86cd799439011",
      "title": "The Butterfly Song",
      "lyrics": "...",
      "audioUrl": "/outputs/song_abc.mp3",
      "timings": [...],
      "duration": 25.5,
      "bpm": 95.0,
      "addedAt": "2024-11-15T12:00:00"
    }
  ]
}

Delete from Library

DELETE /api/library/songs/{song_id}

Cache Endpoints

Get Cached Song

GET /api/cache/{word}

Delete Cached Song

DELETE /api/cache/{word}

🎨 Frontend Features

Pages

  1. Login / Signup

    • Secure authentication with validation
    • Password confirmation
    • Auto-login after signup
  2. Music Mode

    • Topic input with instant validation
    • Real-time progress bar (0-100%)
    • Full-screen karaoke player
    • Add to library button
  3. Library

    • Display all saved songs
    • Play songs instantly (from cache)
    • Delete songs
    • Empty state UI
  4. Karaoke Player

    • Full-screen gradient background
    • Display all lyrics at once (no line-by-line)
    • Play/pause, skip Β±5s controls
    • Progress bar with seek
    • Beautiful animations

User Experience

  • Responsive Design: Works on desktop, tablet, mobile
  • Smooth Animations: Tailwind transitions and transforms
  • Toast Notifications: Success/error messages
  • Loading States: Skeletons and spinners
  • Error Handling: User-friendly error messages
  • Persistent Auth: localStorage for staying logged in

🌐 Deployment

Backend Deployment (Railway/Render)

  1. Railway (Recommended):
# Install Railway CLI
npm install -g @railway/cli

# Login
railway login

# Deploy
railway up
  1. Environment Variables:

    • Add all .env variables to Railway dashboard
    • Set MONGODB_URL to Atlas connection string
    • Set REDIS_URL to Redis Cloud URL
  2. Start Command:

uvicorn app.main:app --host 0.0.0.0 --port $PORT

Frontend Deployment (Vercel/Netlify)

Vercel:

# Install Vercel CLI
npm install -g vercel

# Deploy
cd Frontend/12Tree-frontend
vercel --prod

Build Settings:

  • Build Command: npm run build
  • Output Directory: dist
  • Environment Variable: VITE_API_URL=https://your-backend.railway.app

MongoDB Atlas

  1. Create M0 free cluster
  2. Add IP whitelist (0.0.0.0/0 for development)
  3. Create database user
  4. Get connection string
  5. Replace in .env

Redis Cloud

  1. Create 30MB free database at https://redis.com/try-free/
  2. Get connection URL
  3. Replace in .env

🎯 Core Algorithm: Song Generation

# Simplified pseudocode

def generate_song(word: str):
    # 1. Find rhymes (5-10%)
    rhymes = get_kid_friendly_rhymes(word)

    # 2. Generate lyrics (15-25%)
    lyrics = gemini.create_gentle_educational_song(
        topic=word,
        rhymes=rhymes,
        style="gentle, educational, lullaby-like"
    )

    # 3. Clean lyrics (30%)
    lyrics = remove_pirate_exclamations(lyrics)
    lyrics = remove_structure_labels(lyrics)

    # 4. Generate vocals (40-60%)
    vocals = elevenlabs.text_to_speech(
        text=f"[singing gently and sweetly like a lullaby]\n{lyrics}",
        voice="child_friendly",
        settings={"style": 0.8, "stability": 0.3}
    )

    # 5. Select background music (65-70%)
    track = random.choice(background_tracks)
    duration = get_audio_duration(vocals)
    background = trim_and_fade(track, duration)

    # 6. Mix audio (75-90%)
    final = mix(
        vocals=vocals,
        background=background,
        vocals_volume=1.0,
        background_volume=0.4
    )

    # 7. Generate metadata (95-100%)
    bpm = detect_bpm(final)
    timings = generate_karaoke_timings(vocals, lyrics)

    # 8. Cache and return
    cache.save(word, final, lyrics, timings, bpm)
    return {
        "lyrics": lyrics,
        "audio_url": final.url,
        "timings": timings,
        "duration": duration,
        "bpm": bpm
    }

πŸ” Security Features

  • βœ… Password Hashing: bcrypt with salt
  • βœ… Input Validation: Pydantic models
  • βœ… SQL Injection Prevention: NoSQL (MongoDB)
  • βœ… CORS Protection: Configured origins
  • βœ… Rate Limiting: Celery task limits
  • βœ… User Isolation: Per-user libraries
  • βœ… Environment Variables: Sensitive data in .env

πŸ§ͺ Testing

Backend Tests

# Install pytest
pip install pytest pytest-asyncio

# Run tests
pytest tests/

Frontend Tests

# Install testing library
npm install --save-dev @testing-library/react

# Run tests
npm test

πŸ“Š Performance Metrics

Metric Value
Song Generation Time 30-60 seconds
Cached Song Load < 1 second
API Response Time < 100ms
Frontend Load Time < 2 seconds
Database Query Time < 50ms

🀝 Contributing

We welcome contributions! Here's how:

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/amazing-feature
  3. Commit your changes
    git commit -m 'Add amazing feature'
  4. Push to the branch
    git push origin feature/amazing-feature
  5. Open a Pull Request

Code Style

  • Python: Follow PEP 8, use black formatter
  • TypeScript: Follow ESLint rules, use prettier
  • Commits: Use conventional commits (feat:, fix:, docs:)

πŸ“ License

This project is created for EmoryHack 2024 hackathon.

For educational and demonstration purposes only.


πŸ™ Acknowledgments

  • Google Gemini - Free, powerful AI for lyrics generation
  • ElevenLabs - Professional TTS with singing capabilities
  • Suno Bark - Open-source fallback TTS
  • MongoDB Atlas - Free cloud database
  • Redis Cloud - Free cache and task queue
  • FastAPI - Modern, fast Python web framework
  • React - Powerful UI library
  • Tailwind CSS - Beautiful styling system

πŸ‘₯ Team

Built with ❀️ by the 12Tree Team for EmoryHack 2024


πŸ“ž Contact & Support

  • Issues: Open an issue on GitHub
  • Questions: Check the /Docs folder
  • Demo: Live Demo Link (if deployed)

πŸŽ‰ Try It Now!

# 1. Clone
git clone <repo-url>
cd EmoryHack

# 2. Setup Backend
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env  # Add your API keys!

# 3. Setup Frontend
cd Frontend/12Tree-frontend
npm install

# 4. Start Everything
# Terminal 1: redis-server
# Terminal 2: celery -A app.tasks worker --loglevel=info
# Terminal 3: uvicorn app.main:app --reload
# Terminal 4: npm run dev

# 5. Visit http://localhost:5173

That's it! Start creating educational songs! 🎡


Made with πŸ’œ for preschool learners everywhere

⭐ Star this repo if you found it helpful!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages