Documentation
¶
Overview ¶
Package allproviders is the batteries-included STT assembly layer: it knows every provider SpeechKit ships and turns a host's resolved credentials into a ready stt.Router.
Importing it compiles every provider, which is the right trade for a host that offers a provider choice at runtime — the desktop app, the server. A host that speaks to exactly one backend imports that provider's own package and assembles the router itself, and stays free of the others' dependencies.
It is the single source of truth for STT provider assembly:
- Build/Register map a provider id (or ExecutionMode) to the canonical provider name, endpoint, and constructor.
- BuildRouter assembles a stt.Router from a set of enabled providers so the Device- and Server-Targets share one assembly path while each keeps its own config-resolution specifics (mirrors pkg/speechkit/tts.BuildRouter).
Index ¶
- func Build(spec BuildSpec) (string, stt.STTProvider, error)
- func BuildRouter(cfg RouterConfig, enabled EnabledProviders) (router *stt.Router, ok bool, notes []string)
- func Register(id, name string, build func(BuildSpec) (stt.STTProvider, error)) error
- type AssemblyAIOpts
- type BuildSpec
- type DeepgramOpts
- type EnabledProviders
- type FoundryOpts
- type GoogleOpts
- type GroqOpts
- type HuggingFaceOpts
- type LocalOpts
- type OllamaOpts
- type OpenAIOpts
- type OpenRouterOpts
- type RouterConfig
- type VPSOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
func Build(spec BuildSpec) (string, stt.STTProvider, error)
Build constructs the cloud STT provider for spec and returns its canonical Name plus the provider. spec.Provider (a provider id or profile id) wins; when empty, the provider id is derived from spec.ExecutionMode.
ExecutionModeLocal is host-managed (whisper.cpp subprocess lifecycle) and is intentionally not handled here.
func BuildRouter ¶
func BuildRouter(cfg RouterConfig, enabled EnabledProviders) (router *stt.Router, ok bool, notes []string)
BuildRouter is the single source of truth for assembling an STT router from a set of enabled providers: it constructs each enabled provider in a stable order (cloud fallback order: HuggingFace, OpenRouter, VPS, Ollama, Groq, OpenAI, Deepgram, AssemblyAI, Google, Foundry, then Extra), applies optional model_selection pinning, and returns the router plus human-readable notes. ok is false (router nil) when nothing is enabled.
Types ¶
type AssemblyAIOpts ¶
type AssemblyAIOpts struct {
APIKey string
// Models is the comma-separated STT model list accepted by
// assemblyai.New.
Models string
StreamingModel string
StreamingBaseURL string
SyncBaseURL string
DisableSync bool
// StreamingLLM enables LLM Gateway cleanup on realtime dictation with
// StreamingLLMModel.
StreamingLLM bool
StreamingLLMModel string
}
Per-provider assembly options. These carry the union of what the Device- and Server-Targets configure; nil fields in EnabledProviders are skipped. (deepgram.Options is the existing Listen-option type; the assembly struct is DeepgramOpts and embeds it as Listen.)
type BuildSpec ¶
type BuildSpec struct {
ExecutionMode speechkit.ExecutionMode
Provider string
ModelID string
APIKey string // cloud API key (OpenAI/Groq/Google/Deepgram/AssemblyAI/OpenRouter/Foundry)
Token string // HuggingFace token
BaseURL string // Ollama base URL (optional; defaulted when empty) or Foundry OpenAI-compatible base (required)
// DiarizationModel overrides the Deepgram diarization model (optional).
DiarizationModel string
// Deepgram forwards provider-specific Listen options (optional).
Deepgram deepgram.Options
// Google streaming credential env-var names (optional), forwarded to the
// Google provider so realtime transcription can authenticate.
GoogleStreamingCredentialsEnv string
GoogleApplicationCredentialsEnv string
}
BuildSpec carries the inputs needed to construct a cloud STT provider for a given ExecutionMode. The host config layer resolves secrets and passes them in; the registry owns the provider's canonical name, endpoint, and constructor.
type DeepgramOpts ¶
type DeepgramOpts struct {
APIKey string
Model string
// DiarizationModel overrides the provider default when non-empty.
DiarizationModel string
// Listen forwards Deepgram Listen options (applied when configured).
Listen deepgram.Options
}
Per-provider assembly options. These carry the union of what the Device- and Server-Targets configure; nil fields in EnabledProviders are skipped. (deepgram.Options is the existing Listen-option type; the assembly struct is DeepgramOpts and embeds it as Listen.)
type EnabledProviders ¶
type EnabledProviders struct {
Local *LocalOpts
HuggingFace *HuggingFaceOpts
OpenRouter *OpenRouterOpts
VPS *VPSOpts
Ollama *OllamaOpts
Groq *GroqOpts
OpenAI *OpenAIOpts
Deepgram *DeepgramOpts
AssemblyAI *AssemblyAIOpts
Google *GoogleOpts
Foundry *FoundryOpts
Extra []stt.STTProvider
// Secrets is handed to every constructed provider that resolves
// credentials lazily (currently Google streaming). Nil falls back to the
// process environment.
Secrets stt.SecretResolver
}
EnabledProviders carries the per-provider options a host has already resolved from its own config (credential stores, env secrets, model defaults). Nil fields are skipped. Extra providers are appended after the named ones as additional cloud candidates.
type FoundryOpts ¶ added in v0.67.5
FoundryOpts configures the Microsoft Foundry provider. BaseURL is the OpenAI-compatible base derived from the project endpoint (https://<host>/openai); Model is the deployment name and defaults to "gpt-4o-mini-transcribe" when empty.
type GoogleOpts ¶
type GoogleOpts struct {
APIKey string
Model string
// Streaming credential env-var names forwarded via
// SetStreamingCredentialEnvs.
CredentialsJSONEnv string
ApplicationCredentialsEnv string
}
Per-provider assembly options. These carry the union of what the Device- and Server-Targets configure; nil fields in EnabledProviders are skipped. (deepgram.Options is the existing Listen-option type; the assembly struct is DeepgramOpts and embeds it as Listen.)
type HuggingFaceOpts ¶
Per-provider assembly options. These carry the union of what the Device- and Server-Targets configure; nil fields in EnabledProviders are skipped. (deepgram.Options is the existing Listen-option type; the assembly struct is DeepgramOpts and embeds it as Listen.)
type LocalOpts ¶
LocalOpts configures the host-managed whisper.cpp provider. The provider is registered but not started; process lifecycle stays with the host.
type OllamaOpts ¶
type OllamaOpts struct {
BaseURL string
Model string
// Validation, when non-nil, replaces the provider's default netsec
// validation (loopback+private+http). Restricted network scopes pass
// a RequireLocal option set so public endpoints are rejected at
// request and dial time.
Validation *netsec.ValidationOptions
}
OllamaOpts: BaseURL defaults to "http://localhost:11434" and Model to the provider default when empty.
type OpenAIOpts ¶
OpenAIOpts: Model defaults to "whisper-1" when empty.
type OpenRouterOpts ¶
Per-provider assembly options. These carry the union of what the Device- and Server-Targets configure; nil fields in EnabledProviders are skipped. (deepgram.Options is the existing Listen-option type; the assembly struct is DeepgramOpts and embeds it as Listen.)
type RouterConfig ¶
type RouterConfig struct {
Strategy stt.Strategy
PreferLocalUnderSecs float64
ParallelCloud bool
ReplaceOnBetter bool
// PreferredProfileID optionally pins the cloud provider matching this
// model_selection profile (or bare provider name) to the front of the
// strategy order, analogous to tts.EnabledProviders.PreferredProfileID.
PreferredProfileID string
// OnProviderSelected is installed as the router's per-instance observer
// (stt.Router.OnProviderSelected). Hosts wire audit logging here.
OnProviderSelected stt.ProviderSelectedObserver
}
RouterConfig carries the routing knobs both hosts resolve from their own config before delegating router assembly to BuildRouter.
type VPSOpts ¶
type VPSOpts struct {
URL string
APIKey string
Model string
// Validation, when non-nil, replaces the provider's default netsec
// validation (loopback+private+http). Restricted network scopes pass
// a RequireLocal option set so public endpoints are rejected at
// request and dial time.
Validation *netsec.ValidationOptions
}
VPSOpts configures a self-hosted OpenAI-compatible whisper-server. Model defaults to "whisper-1" when empty.