from pydantic_settings import BaseSettings


class Settings(BaseSettings):
    """Voice service configuration."""

    # Service
    host: str = "0.0.0.0"
    port: int = 3008
    debug: bool = False

    # Claude API
    anthropic_api_key: str = ""
    anthropic_base_url: str = ""
    claude_model: str = "claude-sonnet-4-5-20250514"

    # Agent Service
    agent_service_url: str = "http://agent-service:3002"

    # Voice provider: "local" (Kokoro+faster-whisper) or "openai"
    stt_provider: str = "local"  # "local" or "openai"
    tts_provider: str = "local"  # "local" or "openai"

    # STT (faster-whisper)
    whisper_model: str = "base"
    whisper_language: str = "zh"

    # TTS (Kokoro)
    kokoro_model: str = "kokoro-82m"
    kokoro_voice: str = "zf_xiaoxiao"

    # OpenAI voice
    openai_api_key: str = ""
    openai_base_url: str = ""
    openai_stt_model: str = "gpt-4o-transcribe"
    openai_tts_model: str = "tts-1"
    openai_tts_voice: str = "alloy"

    # Device (cpu or cuda)
    device: str = "cpu"

    # LiveKit
    livekit_api_key: str = "devkey"
    livekit_api_secret: str = "devsecret"
    livekit_ws_url: str = "ws://livekit-server:7880"

    # Twilio
    twilio_account_sid: str = ""
    twilio_auth_token: str = ""
    twilio_phone_number: str = ""

    # Audio
    audio_sample_rate: int = 16000
    audio_channels: int = 1

    # Session
    session_ttl: int = 60  # seconds before disconnected sessions are cleaned up
    heartbeat_interval: int = 15  # seconds between pings
    heartbeat_timeout: int = 45  # seconds before declaring dead connection

    class Config:
        env_file = ".env"


settings = Settings()
