| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- # -*- coding: utf-8 -*-
- """
- Server-Konfiguration.
- """
- from dataclasses import dataclass, field
- from enum import IntFlag
- class ConnectionNotification(IntFlag):
- """Benachrichtigungsoptionen bei Client-Verbindung."""
- NONE = 0
- AUDIO_TTS = 1 << 0 # TTS sagt "Connected"
- AUDIO_WAVE = 1 << 1 # Wave-Datei "connected.wav" abspielen
- @dataclass
- class SatelliteConnectionConfig:
- """Konfiguration für Satellite-Verbindungsbenachrichtigungen."""
- notification: int = 0 # ConnectionNotification Flags
- tts_text: str = "Verbunden"
- wave_file: str = "connected.wav"
- mic_test_tts_text: str = "Teste Mikrofon. Audio wird weitergeleitet"
- @dataclass
- class NetworkConfig:
- """Netzwerk-Konfiguration für den Server."""
- command_port: int = 2101
- audio_input_port: int = 2102
- audio_output_port: int = 2103
- music_port: int = 2104
- config_port: int = 2105
- bind_address: str = "0.0.0.0"
- max_connections: int = 100
- @dataclass
- class SecurityConfig:
- """Sicherheits-Konfiguration."""
- encryption_enabled: bool = True
- encryption_key_path: str = "certs/encryption.key"
- ssl_enabled: bool = False
- ssl_cert_path: str = "certs/server.crt"
- ssl_key_path: str = "certs/server.key"
- allowed_mac_addresses: list[str] = field(default_factory=list)
- @dataclass
- class AudioConfig:
- """Audio-Konfiguration."""
- # Sprach-Audio (Wakeword, STT)
- sample_rate: int = 16000
- channels: int = 1
- bit_depth: int = 16
- # Musik-Streaming (konfigurierbar für Audio-Device-Kompatibilität)
- music_sample_rate: int = 44100 # 44.1kHz - Standard für die meisten Geräte
- music_channels: int = 2
- music_bit_depth: int = 16
- @dataclass
- class WakewordConfig:
- """Wakeword-Erkennungs-Konfiguration."""
- models: list[str] = field(default_factory=lambda: ["custom", "system_command"])
- admin_wakewords: list[str] = field(default_factory=lambda: ["system_command"])
- threshold: float = 0.5
- debounce_seconds: float = 1.0
- arbitration_timeout_seconds: float = 1.0
- min_audio_level: float = 0.0
- min_confidence: float = 0.3
- wakeword_trim_seconds: float = 1.0 # Sekunden am Anfang trimmen (Pre-Buffer + Wakeword-Tail)
- @dataclass
- class VoiceRecognitionConfig:
- """Sprechererkennungs-Konfiguration."""
- model: str = "default"
- enabled: bool = True
- threshold: float = 0.7
- @dataclass
- class ConversationConfig:
- """Konversations-Konfiguration."""
- max_silence_seconds: float = 3.0
- max_duration_seconds: float = 60.0
- timeout_seconds: float = 30.0
- @dataclass
- class PluginConfig:
- """Plugin-Konfiguration."""
- enabled: bool = True
- plugin_directory: str = "plugins"
- auto_reload: bool = False
- @dataclass
- class LoggingConfig:
- """Logging-Konfiguration."""
- level: str = "INFO"
- file_log_level: str = "INFO"
- log_directory: str = "logs"
- max_file_size_mb: int = 10
- backup_count: int = 5
- plugin_timeout_seconds: float = 30.0
- plugin_max_failures: int = 3
- @dataclass
- class STTCorrectionConfig:
- """Konfiguration fuer die STT-Nachkorrektur."""
- enabled: bool = True
- language: str = "de"
- layers: list[str] = field(default_factory=lambda: ["symspell", "phonetic", "kenlm"])
- protected_words: list[str] = field(default_factory=lambda: [
- "Eminem", "Rammstein", "AC/DC", "Trixy", "Alexa",
- "Conan", "Naruto", "Crunchyroll", "Netflix",
- ])
- custom_aliases: dict[str, str] = field(default_factory=lambda: {
- "shop": "stopp",
- "schop": "stopp",
- })
- symspell_max_edit_distance: int = 2
- symspell_dictionary_path: str = ""
- kenlm_model_path: str = "models/kenlm/de.binary"
- jamspell_model_path: str = "models/jamspell/de.bin"
- hunspell_dict_path: str = "/usr/share/hunspell/de_DE"
- languagetool_language: str = "de-DE"
- @dataclass
- class EmailPGPConfig:
- """PGP-Konfiguration fuer den Email-Service."""
- enabled: bool = False
- gpg_home: str = "~/.gnupg"
- sign_key: str = ""
- passphrase: str = ""
- always_sign: bool = False
- always_encrypt: bool = False
- recipient_keys: dict[str, str] = field(default_factory=dict)
- @dataclass
- class EmailServiceConfig:
- """E-Mail-Service Konfiguration (SMTP-Versand + optionales PGP)."""
- smtp_host: str = ""
- smtp_port: int = 587
- smtp_user: str = ""
- smtp_password: str = ""
- smtp_ssl: bool = True
- smtp_starttls: bool = True
- from_address: str = ""
- from_name: str = "Trixy"
- reply_to: str = ""
- organization: str = ""
- pgp: EmailPGPConfig = field(default_factory=EmailPGPConfig)
- @dataclass
- class ServerConfig:
- """Haupt-Server-Konfiguration."""
- network: NetworkConfig = field(default_factory=NetworkConfig)
- security: SecurityConfig = field(default_factory=SecurityConfig)
- audio: AudioConfig = field(default_factory=AudioConfig)
- wakeword: WakewordConfig = field(default_factory=WakewordConfig)
- voice_recognition: VoiceRecognitionConfig = field(default_factory=VoiceRecognitionConfig)
- conversation: ConversationConfig = field(default_factory=ConversationConfig)
- plugins: PluginConfig = field(default_factory=PluginConfig)
- logging: LoggingConfig = field(default_factory=LoggingConfig)
- satellite_connection: SatelliteConnectionConfig = field(default_factory=SatelliteConnectionConfig)
- stt_correction: STTCorrectionConfig = field(default_factory=STTCorrectionConfig)
- email: EmailServiceConfig = field(default_factory=EmailServiceConfig)
- satellites_directory: str = "satellites"
- assets_directory: str = "assets"
- models_directory: str = "models"
- profile: str = "default"
|