Spaces:
Running
Running
File size: 6,016 Bytes
fff13d1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
#!/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 "=========================================="
|