Spaces:
Build error
Build error
| #!/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!") | |