select_provider_with_session_voice_config

Function select_provider_with_session_voice_config 

Source
pub async fn select_provider_with_session_voice_config(
    config: &AppConfig,
    session_voice_config: Option<&SessionVoiceConfig>,
    secrets: Option<&dyn SecretProvider>,
) -> Box<dyn SttProvider>
Expand description

Select an STT provider from configuration, applying optional per-session voice overrides.

This function is the session-aware variant of select_provider. It implements the core-owned precedence rules for per-session overrides:

  • Provider: session.provider (trimmed, non-empty) overrides config.voice.provider
  • OpenAI model: session.model overrides config.voice.openai_model (defaulting to gpt-4o-transcribe) when OpenAI STT is selected
  • Local Whisper model: session.model is interpreted as a path or filename per crate::speech::resolve_whisper_model_path_with_override when local STT is selected

This is intentionally conservative: if required fields (like API keys or model paths) are missing, it returns an UnconfiguredSttProvider with an actionable error message.

If secrets is provided, it will be consulted for API keys using SecretKey fallbacks.