Phase 3 Tasks Completed: - Added model directory validation to VoskService constructor - Added configuration validation to TtsService constructor - Added comprehensive setup instructions to VoskConfig and CoquiConfig - Added AI Model Setup Guide to docs/features/ai-services.md with: - Vosk model download and setup instructions - Coqui TTS model download and setup instructions - Mistral API configuration guide - Verification commands - Troubleshooting table - Updated appsettings.json and appsettings.Development.json with comments All configuration is now validated on service startup with helpful error messages that guide users to download and configure the required models. Build: Success Tests: 296 passing (148 unit + 148 integration) Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
104 lines
3 KiB
C#
104 lines
3 KiB
C#
namespace GermanApp.Infrastructure.Configuration;
|
|
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
public class VoskConfig
|
|
{
|
|
/// <summary>
|
|
/// Path to the Python executable.
|
|
/// Default: python3
|
|
/// </summary>
|
|
public string PythonPath { get; set; } = "python3";
|
|
|
|
/// <summary>
|
|
/// Path to the Vosk model directory.
|
|
/// Example: /models/vosk-model-de-0.22
|
|
/// </summary>
|
|
public string ModelPath { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Expected audio sample rate in Hz.
|
|
/// Vosk models typically use 16000 Hz.
|
|
/// Default: 16000
|
|
/// </summary>
|
|
public int SampleRate { get; set; } = 16000;
|
|
|
|
/// <summary>
|
|
/// Maximum audio duration in seconds for speech recognition.
|
|
/// Default: 60 seconds
|
|
/// </summary>
|
|
public int MaxAudioDurationSeconds { get; set; } = 60;
|
|
|
|
/// <summary>
|
|
/// Timeout in seconds for Vosk processing.
|
|
/// Default: 30 seconds
|
|
/// </summary>
|
|
public int TimeoutSeconds { get; set; } = 30;
|
|
|
|
/// <summary>
|
|
/// Whether to enable beam width adjustment for accuracy vs speed tradeoff.
|
|
/// Higher values = more accurate but slower.
|
|
/// Default: 16
|
|
/// </summary>
|
|
public int BeamWidth { get; set; } = 16;
|
|
|
|
/// <summary>
|
|
/// Path to the Vosk Python package/module.
|
|
/// Default: vosk
|
|
/// </summary>
|
|
public string ModulePath { get; set; } = "vosk";
|
|
|
|
/// <summary>
|
|
/// Validates the configuration.
|
|
/// </summary>
|
|
/// <exception cref="ArgumentException">Thrown when configuration is invalid</exception>
|
|
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");
|
|
}
|
|
}
|
|
}
|