vtbp-video-translate/setup_env.sh
2025-09-02 11:43:56 -05:00

98 lines
No EOL
3.3 KiB
Bash
Executable file

#!/bin/bash
# VTBP Environment Setup Script for Mac
echo "🚀 Setting up VTBP with Google API integration..."
# Check if .env file exists
if [[ ! -f ".env" ]]; then
echo "❌ .env file not found. Please create it first or run this script from the project root."
exit 1
fi
# Check if service account file exists
SERVICE_ACCOUNT_FILE="optical-414516-80e2475f6412.json"
if [[ ! -f "$SERVICE_ACCOUNT_FILE" ]]; then
echo "❌ Service account file not found: $SERVICE_ACCOUNT_FILE"
echo "Please ensure the Google service account JSON file is in the project root."
exit 1
fi
echo "✅ Found service account file: $SERVICE_ACCOUNT_FILE"
# Load environment variables
source .env 2>/dev/null || echo "⚠️ Could not source .env file directly"
# Export the environment variables
echo "📝 Setting up environment variables..."
export GEMINI_API_KEY="AIzaSyAuuVGcvqfoP7pqX-YwieGszPsNSeAft-0"
export GOOGLE_APPLICATION_CREDENTIALS="$SERVICE_ACCOUNT_FILE"
export GOOGLE_CLOUD_PROJECT="optical-414516"
export GOOGLE_CLOUD_LOCATION="us-central1"
echo "✅ Environment variables configured:"
echo " GEMINI_API_KEY: ${GEMINI_API_KEY:0:20}..."
echo " GOOGLE_CLOUD_PROJECT: $GOOGLE_CLOUD_PROJECT"
echo " GOOGLE_APPLICATION_CREDENTIALS: $GOOGLE_APPLICATION_CREDENTIALS"
echo " GOOGLE_CLOUD_LOCATION: $GOOGLE_CLOUD_LOCATION"
# Activate virtual environment if it exists
if [[ -d "venv" ]]; then
echo "🐍 Activating virtual environment..."
source venv/bin/activate
echo "✅ Virtual environment activated"
else
echo "⚠️ Virtual environment not found. Create it with: python3 -m venv venv"
fi
# Check if dependencies are installed
echo "📦 Checking dependencies..."
if pip list | grep -q "google-genai"; then
echo "✅ Google GenAI library installed"
else
echo "❌ Google GenAI library not found. Install with: pip install -r requirements-api.txt"
fi
if pip list | grep -q "google-cloud-texttospeech"; then
echo "✅ Google Cloud TTS library installed"
else
echo "❌ Google Cloud TTS library not found. Install with: pip install -r requirements-api.txt"
fi
# Test API credentials
echo "🔍 Testing API credentials..."
# Test Gemini API
if [[ -n "$GEMINI_API_KEY" ]]; then
echo "✅ Gemini API key configured"
else
echo "❌ Gemini API key not found"
fi
# Test Google Cloud credentials
if [[ -f "$GOOGLE_APPLICATION_CREDENTIALS" ]]; then
echo "✅ Google Cloud service account file found"
# Validate JSON format
if python3 -c "import json; json.load(open('$GOOGLE_APPLICATION_CREDENTIALS'))" 2>/dev/null; then
echo "✅ Service account file is valid JSON"
else
echo "❌ Service account file is not valid JSON"
fi
else
echo "❌ Google Cloud credentials file not found"
fi
echo ""
echo "🎬 Ready to test VTBP! Try these commands:"
echo ""
echo "# Validate API setup:"
echo "vtbp translate --validate-apis --asr-provider gemini --tts-provider google"
echo ""
echo "# Test translation with cost estimation:"
echo "vtbp translate input.mp4 output.mp4 --estimate-cost --asr-provider gemini --tts-provider google"
echo ""
echo "# Full API translation:"
echo "vtbp translate input.mp4 output.mp4 --asr-provider gemini --tts-provider google --translation-provider gemini"
echo ""
echo "🍎 Mac-optimized setup complete!"