namespace GermanApp.Infrastructure.Configuration;
///
/// Configuration settings for Vosk speech recognition service.
/// This is part of the Infrastructure layer.
///
/// Setup Instructions:
/// 1. Install Python 3.8+: https://www.python.org/downloads/
/// 2. Install Vosk: pip install vosk
/// 3. Download German model:
/// wget https://alphacephei.com/vosk/models/vosk-model-de-0.22.zip
/// unzip vosk-model-de-0.22.zip
/// 4. Set ModelPath to the extracted directory (e.g., /models/vosk-model-de-0.22)
///
/// Note: Model requires ~500MB disk space
///
public class VoskConfig
{
///
/// Path to the Python executable.
/// Default: python3
///
public string PythonPath { get; set; } = "python3";
///
/// Path to the Vosk model directory.
/// Example: /models/vosk-model-de-0.22
///
public string ModelPath { get; set; } = string.Empty;
///
/// Expected audio sample rate in Hz.
/// Vosk models typically use 16000 Hz.
/// Default: 16000
///
public int SampleRate { get; set; } = 16000;
///
/// Maximum audio duration in seconds for speech recognition.
/// Default: 60 seconds
///
public int MaxAudioDurationSeconds { get; set; } = 60;
///
/// Timeout in seconds for Vosk processing.
/// Default: 30 seconds
///
public int TimeoutSeconds { get; set; } = 30;
///
/// Whether to enable beam width adjustment for accuracy vs speed tradeoff.
/// Higher values = more accurate but slower.
/// Default: 16
///
public int BeamWidth { get; set; } = 16;
///
/// Path to the Vosk Python package/module.
/// Default: vosk
///
public string ModulePath { get; set; } = "vosk";
///
/// Validates the configuration.
///
/// Thrown when configuration is invalid
public void Validate()
{
if (string.IsNullOrWhiteSpace(PythonPath))
{
throw new ArgumentException("Vosk PythonPath is required");
}
if (string.IsNullOrWhiteSpace(ModelPath))
{
throw new ArgumentException("Vosk ModelPath is required");
}
if (SampleRate <= 0)
{
throw new ArgumentException("SampleRate must be greater than 0");
}
if (MaxAudioDurationSeconds <= 0)
{
throw new ArgumentException("MaxAudioDurationSeconds must be greater than 0");
}
if (TimeoutSeconds <= 0)
{
throw new ArgumentException("TimeoutSeconds must be greater than 0");
}
if (BeamWidth <= 0)
{
throw new ArgumentException("BeamWidth must be greater than 0");
}
if (string.IsNullOrWhiteSpace(ModulePath))
{
throw new ArgumentException("Vosk ModulePath is required");
}
}
}