#!/bin/bash # NeuroAnim Setup Script # This script helps you set up the project environment set -e # Exit on error echo "đŸŽŦ NeuroAnim Setup Script" echo "==========================" echo "" # Color codes for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Function to print colored output print_success() { echo -e "${GREEN}✅ $1${NC}" } print_error() { echo -e "${RED}❌ $1${NC}" } print_warning() { echo -e "${YELLOW}âš ī¸ $1${NC}" } print_info() { echo -e "${BLUE}â„šī¸ $1${NC}" } # Check Python version echo "Checking Python version..." if ! command -v python3 &> /dev/null; then print_error "Python 3 is not installed" exit 1 fi PYTHON_VERSION=$(python3 --version | cut -d' ' -f2) PYTHON_MAJOR=$(echo $PYTHON_VERSION | cut -d'.' -f1) PYTHON_MINOR=$(echo $PYTHON_VERSION | cut -d'.' -f2) if [ "$PYTHON_MAJOR" -lt 3 ] || ([ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -lt 10 ]); then print_error "Python 3.10+ required, found $PYTHON_VERSION" exit 1 fi print_success "Python $PYTHON_VERSION detected" echo "" # Create virtual environment echo "Setting up virtual environment..." if [ -d ".venv" ]; then print_warning "Virtual environment already exists" read -p "Do you want to recreate it? (y/N): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then rm -rf .venv python3 -m venv .venv print_success "Virtual environment recreated" else print_info "Using existing virtual environment" fi else python3 -m venv .venv print_success "Virtual environment created" fi echo "" # Activate virtual environment echo "Activating virtual environment..." source .venv/bin/activate print_success "Virtual environment activated" echo "" # Install dependencies echo "Installing dependencies..." pip install --upgrade pip > /dev/null 2>&1 pip install -e . > /dev/null 2>&1 pip install httpx gtts pydub python-dotenv > /dev/null 2>&1 print_success "Dependencies installed" echo "" # Setup .env file echo "Configuring environment variables..." if [ -f ".env" ]; then print_warning ".env file already exists" read -p "Do you want to update it? (y/N): " -n 1 -r echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then print_info "Skipping .env configuration" echo "" echo "==========================================" print_success "Setup complete!" echo "" echo "To activate the virtual environment:" echo " source .venv/bin/activate" echo "" echo "To generate your first animation:" echo " python example.py" echo "" echo "For more information, see QUICKSTART.md" echo "==========================================" exit 0 fi fi echo "" echo "Let's set up your API keys..." echo "" # Hugging Face API Key print_info "Hugging Face API Key (Required)" echo " Get it from: https://huggingface.co/settings/tokens" echo " Free account available" read -p "Enter your Hugging Face API key (hf_...): " HF_API_KEY echo "" # ElevenLabs API Key print_info "ElevenLabs API Key (Recommended for high-quality audio)" echo " Get it from: https://elevenlabs.io (Profile → API Key)" echo " Free tier: 10,000 characters/month" read -p "Enter your ElevenLabs API key (sk_...) or press Enter to skip: " ELEVENLABS_API_KEY echo "" # Create .env file cat > .env << EOF # NeuroAnim Environment Configuration # Generated by setup.sh on $(date) # =========================================== # Required: Hugging Face API Key # =========================================== # Used for: # - Concept planning # - Code generation # - Narration generation # - Quiz generation # Get it from: https://huggingface.co/settings/tokens HUGGINGFACE_API_KEY=${HF_API_KEY} # =========================================== # Recommended: ElevenLabs API Key # =========================================== # Used for: # - High-quality text-to-speech # Get it from: https://elevenlabs.io # Free tier: 10,000 characters/month (~10 animations) # If not set, will fallback to Hugging Face TTS (lower quality) EOF if [ -n "$ELEVENLABS_API_KEY" ]; then echo "ELEVENLABS_API_KEY=${ELEVENLABS_API_KEY}" >> .env else echo "# ELEVENLABS_API_KEY=sk_your_key_here" >> .env fi cat >> .env << EOF # =========================================== # Optional: Blaxel Sandbox (for cloud rendering) # =========================================== # Only needed if you want to use cloud-based rendering # Get it from: https://blaxel.ai # BL_API_KEY=your_blaxel_api_key_here # BL_WORKSPACE=your_workspace_id_here # =========================================== # Development Settings # =========================================== # LOG_LEVEL=INFO # MANIM_QUALITY=medium # MANIM_FPS=30 EOF print_success ".env file created successfully" echo "" # Test the setup echo "Testing setup..." if [ -n "$HF_API_KEY" ]; then print_success "Hugging Face API key configured" else print_warning "Hugging Face API key is empty - animations will fail" fi if [ -n "$ELEVENLABS_API_KEY" ]; then print_success "ElevenLabs API key configured" else print_warning "ElevenLabs API key not set - will use lower quality TTS" fi echo "" # Final instructions echo "==========================================" print_success "Setup complete!" echo "" echo "Quick Start:" echo " 1. Activate virtual environment:" echo " ${BLUE}source .venv/bin/activate${NC}" echo "" echo " 2. Generate your first animation:" echo " ${BLUE}python example.py${NC}" echo "" echo " 3. Or use command line:" echo " ${BLUE}python orchestrator.py \"photosynthesis\"${NC}" echo "" echo "Documentation:" echo " - Quick Start: ${BLUE}QUICKSTART.md${NC}" echo " - ElevenLabs Guide: ${BLUE}ELEVENLABS_SETUP.md${NC}" echo " - Code Generation: ${BLUE}CODE_GENERATION_IMPROVEMENTS.md${NC}" echo "" echo "Output files will be saved to: ${BLUE}outputs/${NC}" echo "=========================================="