Spaces:
Sleeping
Sleeping
| """Configuration for AI Radio App""" | |
| import os | |
| from pydantic import BaseModel | |
| class RadioConfig(BaseModel): | |
| """Configuration for the radio app""" | |
| # API Keys - MUST be set via environment variables (secrets in HF Spaces) | |
| # These defaults are empty strings - will fail if not set via env vars | |
| elevenlabs_api_key: str = "" | |
| llamaindex_api_key: str = "" | |
| nebius_api_key: str = "" | |
| # Nebius OpenAI-compatible endpoint and model | |
| nebius_api_base: str = "https://api.tokenfactory.nebius.com/v1/" # Nebius OpenAI-compatible endpoint | |
| nebius_model: str = "openai/gpt-oss-120b" # GPT-OSS-120B model name from Nebius | |
| # Voice Settings | |
| elevenlabs_voice_id: str = "21m00Tcm4TlvDq8ikWAM" # Default voice (Rachel) | |
| # Radio Station Settings | |
| station_name: str = "AI Radio 🎵" | |
| station_tagline: str = "Your Personal AI-Powered Radio Station" | |
| # Segments configuration | |
| music_ratio: float = 0.5 | |
| news_ratio: float = 0.2 | |
| podcast_ratio: float = 0.2 | |
| story_ratio: float = 0.1 | |
| def get_config() -> RadioConfig: | |
| """Get configuration from environment variables (secrets in HF Spaces)""" | |
| config = RadioConfig() | |
| # Read API keys from environment variables (required for HF Spaces) | |
| # These should be set as Secrets in HuggingFace Spaces Settings | |
| config.elevenlabs_api_key = os.getenv("ELEVENLABS_API_KEY", "") | |
| config.llamaindex_api_key = os.getenv("LLAMAINDEX_API_KEY", "") | |
| config.nebius_api_key = os.getenv("NEBIUS_API_KEY", "") | |
| # Validate that required keys are set | |
| if not config.elevenlabs_api_key: | |
| print("⚠️ Warning: ELEVENLABS_API_KEY not set. TTS will not work.") | |
| if not config.nebius_api_key: | |
| print("⚠️ Warning: NEBIUS_API_KEY not set. LLM will not work.") | |
| return config | |