Spaces:
Sleeping
Sleeping
| """ | |
| VoiceForge Configuration | |
| Pydantic Settings for application configuration | |
| """ | |
| from functools import lru_cache | |
| from typing import List | |
| from pydantic_settings import BaseSettings, SettingsConfigDict | |
| from pydantic import Field | |
| class Settings(BaseSettings): | |
| """Application settings loaded from environment variables""" | |
| model_config = SettingsConfigDict( | |
| env_file=".env", | |
| env_file_encoding="utf-8", | |
| case_sensitive=False, | |
| extra="allow", # Allow extra env vars without error | |
| ) | |
| # Application | |
| app_name: str = "VoiceForge" | |
| app_version: str = "1.0.0" | |
| debug: bool = False | |
| # API Server | |
| api_host: str = "0.0.0.0" | |
| api_port: int = 8000 | |
| # Database | |
| database_url: str = Field( | |
| default="sqlite:///./voiceforge.db", | |
| description="Database connection URL (SQLite for dev, PostgreSQL for prod)" | |
| ) | |
| # Redis | |
| redis_url: str = Field( | |
| default="redis://localhost:6379/0", | |
| description="Redis connection URL for caching and Celery" | |
| ) | |
| # Google Cloud | |
| google_application_credentials: str = Field( | |
| default="./credentials/google-cloud-key.json", | |
| description="Path to Google Cloud service account JSON key" | |
| ) | |
| # AI Services Configuration | |
| use_local_services: bool = Field( | |
| default=True, | |
| description="Use local free services (Whisper + EdgeTTS) instead of Google Cloud" | |
| ) | |
| whisper_model: str = Field( | |
| default="small", | |
| description="Whisper model size (tiny, base, small, medium, large-v3)" | |
| ) | |
| # Security | |
| secret_key: str = Field( | |
| default="your-super-secret-key-change-in-production", | |
| description="Secret key for JWT encoding" | |
| ) | |
| access_token_expire_minutes: int = 30 | |
| algorithm: str = "HS256" | |
| hf_token: str | None = Field(default=None, description="Hugging Face Token for Diarization") | |
| # File Storage | |
| upload_dir: str = "./uploads" | |
| max_audio_duration_seconds: int = 600 # 10 minutes | |
| max_upload_size_mb: int = 50 | |
| # Supported Languages | |
| supported_languages: str = "en-US,en-GB,es-ES,es-MX,fr-FR,de-DE,ja-JP,ko-KR,zh-CN,hi-IN" | |
| # Audio Formats | |
| supported_audio_formats: str = "wav,mp3,m4a,flac,ogg,webm" | |
| def supported_languages_list(self) -> List[str]: | |
| """Get supported languages as a list""" | |
| return [lang.strip() for lang in self.supported_languages.split(",")] | |
| def supported_audio_formats_list(self) -> List[str]: | |
| """Get supported audio formats as a list""" | |
| return [fmt.strip() for fmt in self.supported_audio_formats.split(",")] | |
| # Language metadata for UI display | |
| LANGUAGE_METADATA = { | |
| "en-US": {"name": "English (US)", "flag": "🇺🇸", "native": "English"}, | |
| "en-GB": {"name": "English (UK)", "flag": "🇬🇧", "native": "English"}, | |
| "es-ES": {"name": "Spanish (Spain)", "flag": "🇪🇸", "native": "Español"}, | |
| "es-MX": {"name": "Spanish (Mexico)", "flag": "🇲🇽", "native": "Español"}, | |
| "fr-FR": {"name": "French", "flag": "🇫🇷", "native": "Français"}, | |
| "de-DE": {"name": "German", "flag": "🇩🇪", "native": "Deutsch"}, | |
| "ja-JP": {"name": "Japanese", "flag": "🇯🇵", "native": "日本語"}, | |
| "ko-KR": {"name": "Korean", "flag": "🇰🇷", "native": "한국어"}, | |
| "zh-CN": {"name": "Chinese (Mandarin)", "flag": "🇨🇳", "native": "中文"}, | |
| "hi-IN": {"name": "Hindi", "flag": "🇮🇳", "native": "हिन्दी"}, | |
| } | |
| def get_settings() -> Settings: | |
| """Get cached settings instance""" | |
| return Settings() | |