nca-toolkit / config.py
ismdrobiul489's picture
Change port to 8880 and update uvicorn args
a4fc0b9
import os
from pathlib import Path
from pydantic_settings import BaseSettings
from typing import Optional
class Config(BaseSettings):
"""Application configuration from environment variables"""
# API Keys
pexels_api_key: Optional[str] = None
hf_tts: Optional[str] = None
# Server Configuration
port: int = 8880
log_level: str = "info"
# System Configuration
whisper_model: str = "tiny.en"
whisper_verbose: bool = False
concurrency: int = 1
video_cache_size_in_bytes: int = 2684354560 # 2.5GB
# Docker/Environment
docker: bool = False
dev: bool = False
data_dir_path: Optional[str] = None
class Config:
env_file = ".env"
case_sensitive = False
extra = "ignore"
@property
def base_data_dir(self) -> Path:
"""Get the base data directory path"""
if self.data_dir_path:
return Path(self.data_dir_path)
if self.docker:
return Path("/data")
# For local development
home = Path.home()
return home / ".short-video-maker"
@property
def videos_dir_path(self) -> Path:
"""Directory for storing generated videos"""
path = self.base_data_dir / "videos"
path.mkdir(parents=True, exist_ok=True)
return path
@property
def temp_dir_path(self) -> Path:
"""Directory for temporary files"""
path = self.base_data_dir / "temp"
path.mkdir(parents=True, exist_ok=True)
return path
@property
def music_dir_path(self) -> Path:
"""Directory for music files"""
# Music files are bundled with the application
return Path(__file__).parent / "static" / "music"
@property
def whisper_model_dir(self) -> Path:
"""Directory for Whisper models"""
path = self.base_data_dir / "whisper_models"
path.mkdir(parents=True, exist_ok=True)
return path
def ensure_directories(self):
"""Ensure all required directories exist"""
self.videos_dir_path.mkdir(parents=True, exist_ok=True)
self.temp_dir_path.mkdir(parents=True, exist_ok=True)
self.whisper_model_dir.mkdir(parents=True, exist_ok=True)
# Global config instance
config = Config()