CatPtain commited on
Commit
239fb8e
Β·
verified Β·
1 Parent(s): 1685bf2

Upload 5 files

Browse files
Files changed (3) hide show
  1. app.py +71 -0
  2. packages.txt +1 -6
  3. requirements.txt +6 -27
app.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Huggingface Spaces entry point for MoneyPrinterTurbo
4
+ This file replaces main.py for HF Spaces deployment
5
+ """
6
+ import os
7
+ import sys
8
+ import subprocess
9
+ import time
10
+
11
+ # Add the root directory to Python path
12
+ root_dir = os.path.dirname(os.path.abspath(__file__))
13
+ sys.path.insert(0, root_dir)
14
+
15
+ def setup_environment():
16
+ """Setup environment for Huggingface Spaces"""
17
+ print("πŸ“ Creating storage directories...")
18
+ # Create necessary directories
19
+ os.makedirs(os.path.join(root_dir, "storage", "tasks"), exist_ok=True)
20
+ os.makedirs(os.path.join(root_dir, "storage", "cache_videos"), exist_ok=True)
21
+ os.makedirs(os.path.join(root_dir, "storage", "temp"), exist_ok=True)
22
+
23
+ # Set environment variables for Huggingface Spaces
24
+ os.environ["STREAMLIT_SERVER_PORT"] = "7860"
25
+ os.environ["STREAMLIT_SERVER_ADDRESS"] = "0.0.0.0"
26
+ os.environ["STREAMLIT_BROWSER_GATHER_USAGE_STATS"] = "false"
27
+ os.environ["STREAMLIT_SERVER_ENABLE_CORS"] = "true"
28
+
29
+ def setup_api_keys_from_env():
30
+ """Setup API keys from environment variables (minimal version)"""
31
+ try:
32
+ from app.config import config
33
+
34
+ # Only load essential API keys for faster startup
35
+ if os.getenv("MONEYPRINTER_API_KEY"):
36
+ config.app["api_key"] = os.getenv("MONEYPRINTER_API_KEY")
37
+ config.app["api_enabled"] = True
38
+ print("βœ… API access configured")
39
+
40
+ # Save minimal config
41
+ config.save_config()
42
+
43
+ except Exception as e:
44
+ print(f"⚠️ Warning: {e}")
45
+ print("πŸ’‘ Configure API keys in WebUI after startup")
46
+
47
+ def start_streamlit():
48
+ """Start Streamlit app optimized for HF Spaces"""
49
+ print("πŸš€ Starting MoneyPrinterTurbo WebUI...")
50
+
51
+ streamlit_cmd = [
52
+ sys.executable, "-m", "streamlit", "run",
53
+ os.path.join(root_dir, "webui", "Main.py"),
54
+ "--server.port=7860",
55
+ "--server.address=0.0.0.0",
56
+ "--browser.gatherUsageStats=false",
57
+ "--server.enableCORS=true"
58
+ ]
59
+
60
+ # Replace current process with Streamlit
61
+ os.execvp(sys.executable, streamlit_cmd)
62
+
63
+ if __name__ == "__main__":
64
+ print("πŸš€ MoneyPrinterTurbo - Huggingface Spaces")
65
+
66
+ # Minimal setup for fast startup
67
+ setup_environment()
68
+ setup_api_keys_from_env()
69
+
70
+ # Start Streamlit (this replaces the current process)
71
+ start_streamlit()
packages.txt CHANGED
@@ -1,6 +1 @@
1
- ffmpeg
2
- libsm6
3
- libxext6
4
- libxrender-dev
5
- libglib2.0-0
6
- libgl1-mesa-glx
 
1
+ ffmpeg
 
 
 
 
 
requirements.txt CHANGED
@@ -1,43 +1,22 @@
1
  # Core dependencies
2
  streamlit==1.45.0
3
- fastapi==0.115.6
4
- uvicorn==0.34.0
5
 
6
- # Video processing
7
  moviepy==2.1.1
8
  imageio-ffmpeg==0.5.1
9
  Pillow>=10.0.0
10
 
11
- # AI/LLM providers
12
  openai==1.56.1
13
- google-generativeai==0.8.3
14
-
15
- # Text-to-Speech
16
  edge-tts==6.1.19
17
- azure-cognitiveservices-speech==1.40.0
18
 
19
- # HTTP and API
20
  requests>=2.31.0
21
- httpx>=0.25.0
22
- python-multipart==0.0.19
23
-
24
- # Configuration and data
25
  pyyaml>=6.0
26
  toml>=0.10.0
27
- pydantic>=2.0.0
28
 
29
- # Logging and utilities
30
  loguru==0.7.3
31
 
32
- # Background tasks
33
- celery==5.3.4
34
- redis>=4.0.0
35
-
36
- # System utilities
37
- psutil>=5.9.0
38
-
39
- # Audio processing (lightweight alternatives)
40
- pydub>=0.25.0
41
-
42
- # For Huggingface Spaces compatibility
43
- gradio-client>=0.7.0
 
1
  # Core dependencies
2
  streamlit==1.45.0
 
 
3
 
4
+ # Video processing (essential only)
5
  moviepy==2.1.1
6
  imageio-ffmpeg==0.5.1
7
  Pillow>=10.0.0
8
 
9
+ # AI/LLM providers (lightweight)
10
  openai==1.56.1
 
 
 
11
  edge-tts==6.1.19
 
12
 
13
+ # HTTP and configuration
14
  requests>=2.31.0
 
 
 
 
15
  pyyaml>=6.0
16
  toml>=0.10.0
 
17
 
18
+ # Logging
19
  loguru==0.7.3
20
 
21
+ # Audio processing
22
+ pydub>=0.25.0