#!/usr/bin/env python3 """ Quick script to create .env file with Keith's Hugging Face token """ import sys from pathlib import Path # Fix Windows console encoding for emojis if sys.platform == "win32": import io sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace') sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace') # Your Hugging Face token # Replace with your actual token from https://huggingface.co/settings/tokens HF_TOKEN = "YOUR_HUGGINGFACE_TOKEN_HERE" # Generate secure secret key import secrets SECRET_KEY = secrets.token_urlsafe(32) # .env content env_content = f"""# ═══════════════════════════════════════════════════════════ # AudioForge Backend Environment Configuration # Auto-generated for Keith - January 16, 2026 # ═══════════════════════════════════════════════════════════ # ───────────────────────────────────────────────────────── # Application Settings # ───────────────────────────────────────────────────────── DEBUG=true ENVIRONMENT=development LOG_LEVEL=DEBUG # Secret key for session management SECRET_KEY={SECRET_KEY} # ───────────────────────────────────────────────────────── # Database Configuration # ───────────────────────────────────────────────────────── # Development: Uses Docker port 5433 (container's 5432 mapped to host 5433) # Production: Update to your production database URL DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5433/audioforge # Database pool settings DB_POOL_SIZE=20 DB_MAX_OVERFLOW=10 DB_POOL_TIMEOUT=30 # ───────────────────────────────────────────────────────── # Redis Configuration # ───────────────────────────────────────────────────────── REDIS_URL=redis://localhost:6379/0 REDIS_MAX_CONNECTIONS=50 # ───────────────────────────────────────────────────────── # AI Models Configuration # ───────────────────────────────────────────────────────── # Hugging Face Token (CONFIGURED ✅) HUGGINGFACE_TOKEN={HF_TOKEN} HF_TOKEN={HF_TOKEN} # Device configuration (cpu for development, cuda for production with GPU) MUSICGEN_DEVICE=cpu BARK_DEVICE=cpu DEMUCS_DEVICE=cpu # Model versions MUSICGEN_MODEL=facebook/musicgen-small BARK_MODEL=suno/bark-small DEMUCS_MODEL=htdemucs # ───────────────────────────────────────────────────────── # Audio Processing Settings # ───────────────────────────────────────────────────────── MAX_AUDIO_DURATION=300 DEFAULT_AUDIO_DURATION=30 AUDIO_SAMPLE_RATE=32000 AUDIO_FORMAT=wav # Storage paths STORAGE_PATH=./storage AUDIO_OUTPUT_PATH=./storage/audio # ───────────────────────────────────────────────────────── # API Configuration # ───────────────────────────────────────────────────────── API_V1_PREFIX=/api/v1 API_TITLE=AudioForge API API_VERSION=1.0.0 # CORS settings ALLOWED_ORIGINS=http://localhost:3000,http://localhost:3001 # Rate limiting RATE_LIMIT_PER_MINUTE=60 RATE_LIMIT_PER_HOUR=1000 # ───────────────────────────────────────────────────────── # Celery Configuration # ───────────────────────────────────────────────────────── CELERY_BROKER_URL=redis://localhost:6379/1 CELERY_RESULT_BACKEND=redis://localhost:6379/2 CELERY_TASK_TRACK_STARTED=true CELERY_TASK_TIME_LIMIT=3600 # ───────────────────────────────────────────────────────── # Monitoring # ───────────────────────────────────────────────────────── ENABLE_METRICS=true METRICS_PORT=9090 # ───────────────────────────────────────────────────────── # Feature Flags # ───────────────────────────────────────────────────────── ENABLE_VOCALS=true ENABLE_MASTERING=true ENABLE_STEM_SEPARATION=true ENABLE_AUDIO_EFFECTS=true # ───────────────────────────────────────────────────────── # Development Settings # ───────────────────────────────────────────────────────── RELOAD=true SHOW_ERROR_DETAILS=true # ───────────────────────────────────────────────────────── # Notes # ───────────────────────────────────────────────────────── # ✅ Hugging Face token configured # ✅ Development environment ready # ✅ All features enabled # # Next steps: # 1. cd backend # 2. pip install -e ".[dev]" # 3. python scripts/init_db.py # 4. uvicorn app.main:app --reload # # 🐼⚡ Ready to forge some audio! """ # Write .env file script_dir = Path(__file__).parent project_root = script_dir.parent backend_dir = project_root / "backend" env_file = backend_dir / ".env" env_file.write_text(env_content, encoding="utf-8") print("✅ .env file created successfully!") print(f"📁 Location: {env_file}") print() print("🔑 Configuration:") print(f" ✅ Hugging Face Token: {HF_TOKEN[:20]}...") print(f" ✅ Secret Key: {SECRET_KEY[:20]}...") print(f" ✅ Environment: development") print(f" ✅ Device: cpu") print() print("📋 Next Steps:") print(" 1. cd backend") print(" 2. pip install -e \".[dev]\"") print(" 3. python scripts/init_db.py") print(" 4. uvicorn app.main:app --reload") print() print("🐼⚡ Your environment is ready to go!")