#!/bin/bash # Setup script for Python backend echo "🚀 Setting up React Video Editor Python Backend..." # Check Python version echo "📌 Checking Python version..." python_version=$(python3 --version 2>&1 | awk '{print $2}') required_version="3.9" if [ "$(printf '%s\n' "$required_version" "$python_version" | sort -V | head -n1)" != "$required_version" ]; then echo "❌ Python 3.9 or higher is required. Found: $python_version" exit 1 fi echo "✅ Python $python_version" # Check for ffmpeg echo "📌 Checking for ffmpeg..." if command -v ffmpeg &> /dev/null; then echo "✅ ffmpeg is installed" else echo "⚠️ ffmpeg not found. Install it for video processing:" echo " macOS: brew install ffmpeg" echo " Ubuntu: sudo apt install ffmpeg" fi # Create virtual environment echo "📦 Creating virtual environment..." python3 -m venv venv # Activate virtual environment echo "🔧 Activating virtual environment..." source venv/bin/activate # Upgrade pip echo "📦 Upgrading pip..." pip install --upgrade pip # Install dependencies echo "📦 Installing dependencies..." pip install -r requirements.txt echo "" echo "📦 Installing optional video processing (moviepy)..." pip install moviepy echo "" echo "📦 Attempting to install Whisper..." echo " Note: Whisper may fail on Python 3.13" pip install git+https://github.com/openai/whisper.git || { echo "⚠️ Whisper installation failed (this is okay!)" echo " Backend will use fixed timestamps instead" echo " See WHISPER_INSTALL.md for manual installation" } # Create storage directories echo "📁 Creating storage directories..." mkdir -p storage/images mkdir -p storage/videos # Copy env file if it doesn't exist if [ ! -f .env.local ]; then echo "📝 Creating .env.local from template..." cat > .env.local << EOF # Server Configuration SERVER_PORT=4000 PUBLIC_URL=http://localhost:4000 # API Keys KIE_API_KEY=your_kie_api_key_here VITE_GEMINI_API_KEY=your_gemini_api_key_here # Get your KIE API key at: https://kie.ai/api-key # Get your Gemini API key at: https://makersuite.google.com/app/apikey EOF echo "⚠️ Please edit .env.local and add your API keys" else echo "✅ .env.local already exists" fi echo "" echo "✅ Setup complete!" echo "" echo "🎉 Whisper installed! Frame extraction will now:" echo " - Detect actual last spoken word" echo " - Extract frames from post-speech zone" echo " - Provide intelligent transition frames" echo "" echo "Next steps:" echo "1. Edit .env.local and add your API keys" echo "2. Activate virtual environment: source venv/bin/activate" echo "3. Run the server: python main.py" echo "" echo "Or use Docker:" echo "docker-compose up"