CatPtain's picture
Upload 49 files
6d4ec85 verified
import os
import shutil
import toml
from loguru import logger
root_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
config_file = f"{root_dir}/config.toml"
def load_config():
"""Simplified config loading for faster startup"""
# Skip directory check and example file copying for speed
if not os.path.isfile(config_file):
logger.warning(f"Config file not found: {config_file}, using defaults")
return {
"app": {"max_concurrent_tasks": 1, "api_enabled": True},
"ui": {"hide_log": False},
"azure": {},
"siliconflow": {},
"whisper": {},
"proxy": {}
}
try:
return toml.load(config_file)
except Exception as e:
logger.warning(f"Config load failed: {e}, using defaults")
return {
"app": {"max_concurrent_tasks": 1, "api_enabled": True},
"ui": {"hide_log": False},
"azure": {},
"siliconflow": {},
"whisper": {},
"proxy": {}
}
def save_config():
"""Save current config to file"""
try:
with open(config_file, "w", encoding="utf-8") as f:
_cfg["app"] = app
_cfg["azure"] = azure
_cfg["siliconflow"] = siliconflow
_cfg["ui"] = ui
f.write(toml.dumps(_cfg))
except Exception as e:
logger.warning(f"Failed to save config: {e}")
# Load config with minimal overhead
_cfg = load_config()
app = _cfg.get("app", {})
whisper = _cfg.get("whisper", {})
proxy = _cfg.get("proxy", {})
azure = _cfg.get("azure", {})
siliconflow = _cfg.get("siliconflow", {})
ui = _cfg.get("ui", {"hide_log": False})
# Minimal project info
project_name = "MoneyPrinterTurbo"
project_version = "1.2.6"
project_description = "AI Video Generator"
# HF Spaces optimized settings
log_level = "INFO" # Reduce log verbosity
listen_host = "0.0.0.0"
listen_port = 8080
reload_debug = False
# Skip ImageMagick and FFmpeg path setup for faster startup
# These will be handled by the system packages
logger.info(f"{project_name} v{project_version} - Huggingface Spaces")