namespace GermanApp.Infrastructure.Configuration; /// /// Configuration settings for Coqui TTS service. /// This is part of the Infrastructure layer. /// public class CoquiConfig { /// /// Path to the Python executable. /// Default: python3 /// public string PythonPath { get; set; } = "python3"; /// /// Name of the Coqui TTS model to use. /// Example: tts_models/de/deu/fairseq/vits /// public string ModelName { get; set; } = "tts_models/de/deu/fairseq/vits"; /// /// Path to the TTS Python package/module. /// Default: TTS /// public string ModulePath { get; set; } = "TTS"; /// /// Output audio format. /// Supported: wav, mp3, ogg, flac /// Default: wav /// public string OutputFormat { get; set; } = "wav"; /// /// Output audio sample rate in Hz. /// Default: 22050 /// public int SampleRate { get; set; } = 22050; /// /// Voice speaker ID for the model. /// Default: (empty - uses model default) /// public string Speaker { get; set; } = string.Empty; /// /// Language code for TTS. /// Default: de /// public string Language { get; set; } = "de"; /// /// Maximum text length in characters for a single TTS request. /// Longer texts will be split. /// Default: 500 characters /// public int MaxTextLength { get; set; } = 500; /// /// Timeout in seconds for TTS processing. /// Default: 60 seconds /// public int TimeoutSeconds { get; set; } = 60; /// /// Path to store generated audio files. /// Default: /var/audio/tts /// public string AudioStoragePath { get; set; } = "/var/audio/tts"; /// /// Whether to use GPU acceleration if available. /// Default: false /// public bool UseGPU { get; set; } = false; /// /// Validates the configuration. /// /// Thrown when configuration is invalid public void Validate() { if (string.IsNullOrWhiteSpace(PythonPath)) { throw new ArgumentException("Coqui PythonPath is required"); } if (string.IsNullOrWhiteSpace(ModelName)) { throw new ArgumentException("Coqui ModelName is required"); } if (string.IsNullOrWhiteSpace(ModulePath)) { throw new ArgumentException("Coqui ModulePath is required"); } if (string.IsNullOrWhiteSpace(OutputFormat)) { throw new ArgumentException("Coqui OutputFormat is required"); } var validFormats = new[] { "wav", "mp3", "ogg", "flac" }; if (!validFormats.Contains(OutputFormat.ToLower())) { throw new ArgumentException( $"Invalid OutputFormat '{OutputFormat}'. Valid formats: {string.Join(", ", validFormats)}"); } if (SampleRate <= 0) { throw new ArgumentException("SampleRate must be greater than 0"); } if (MaxTextLength <= 0) { throw new ArgumentException("MaxTextLength must be greater than 0"); } if (TimeoutSeconds <= 0) { throw new ArgumentException("TimeoutSeconds must be greater than 0"); } if (string.IsNullOrWhiteSpace(AudioStoragePath)) { throw new ArgumentException("AudioStoragePath is required"); } } }