Spaces:
Build error
Build error
File size: 7,841 Bytes
09fa60b |
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 |
#!/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!")
|