Spaces:
No application file
No application file
| import os | |
| from typing import Dict, Any | |
| from pydantic import BaseSettings | |
| class Settings(BaseSettings): | |
| """Application settings with validation""" | |
| # API Settings | |
| API_V1_PREFIX: str = "/api/v1" | |
| PROJECT_NAME: str = "Emotion Detection API" | |
| VERSION: str = "1.0.0" | |
| # Security - Critical: These must be set in environment | |
| HF_TOKEN: str | |
| API_SECRET_KEY: str | |
| ALGORITHM: str = "HS256" | |
| ACCESS_TOKEN_EXPIRE_MINUTES: int = 30 | |
| # Model Configuration | |
| ENABLED_MODELS: Dict[str, Dict[str, Any]] = { | |
| "emotion2vec_plus": { | |
| "url": "https://api-inference.huggingface.co/models/emotion2vec/emotion2vec_plus_base", | |
| "weight": 0.50, | |
| "timeout": 30, | |
| "enabled": True | |
| }, | |
| "meralion_ser": { | |
| "url": "https://api-inference.huggingface.co/models/MERaLiON/MERaLiON-SER-v1", | |
| "weight": 0.25, | |
| "timeout": 30, | |
| "enabled": True | |
| }, | |
| "wav2vec2_english": { | |
| "url": "https://api-inference.huggingface.co/models/ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition", | |
| "weight": 0.15, | |
| "timeout": 25, | |
| "enabled": True | |
| }, | |
| "hubert_er": { | |
| "url": "https://api-inference.huggingface.co/models/superb/hubert-large-superb-er", | |
| "weight": 0.07, | |
| "timeout": 25, | |
| "enabled": True | |
| }, | |
| "gigam_emo": { | |
| "url": "https://api-inference.huggingface.co/models/salute-developers/GigaAM-emo", | |
| "weight": 0.03, | |
| "timeout": 20, | |
| "enabled": True | |
| } | |
| } | |
| # Audio Processing | |
| MAX_FILE_SIZE_MB: int = 10 | |
| SUPPORTED_FORMATS: list = ["wav", "mp3", "m4a", "ogg", "flac", "aac"] | |
| TARGET_SAMPLE_RATE: int = 16000 | |
| # Rate Limiting | |
| RATE_LIMIT_REQUESTS: int = 60 | |
| RATE_LIMIT_PERIOD: int = 60 # seconds | |
| class Config: | |
| env_file = ".env" | |
| case_sensitive = True | |
| settings = Settings() |