Documentation
¶
Overview ¶
Package stt defines the SpeechKit speech-to-text contracts: the STTProvider interface, transcribe options and results, the Router that picks a provider per request, the AsTranscriber bridge into the pipeline, and the helpers the adapters share. It names no provider.
The concrete adapters live in subpackages: local (whisper.cpp built-in), openaicompat (OpenAI, Groq, Ollama and other compatible servers), vps (self-hosted whisper-server), huggingface, openrouter, deepgram, assemblyai and azurespeech; allproviders assembles all of them and sttcontract is their conformance suite. Every adapter dials through github.com/kombifyio/SpeechKit/pkg/speechkit/netsec.
Stability: Stable — no breaking change without a minor version bump and a changelog callout.
Index ¶
- Constants
- Variables
- func ApplyResolvedDictationStreamOptions(opts speechkit.DictationStreamOptions, resolved ResolvedTranscribeOptions) speechkit.DictationStreamOptions
- func AsTranscriber(p STTProvider, opts ...TranscriberOption) speechkit.Transcriber
- func BaseCapabilities() []speechkit.Capability
- func ClassifyTransportError(provider string, err error) error
- func EnsureTranscriptionWAV(raw []byte) []byte
- func EnvSecretResolver(name string) string
- func FirstNonEmptyTrimmed(values ...string) string
- func IsMultilanguage(language string) bool
- func IsWAV(raw []byte) bool
- func IsWebSocketClose(err error) bool
- func MaxSpeakers(opts speaker.Options) int
- func MinSpeakers(opts speaker.Options) int
- func PCM16FromWAV(audio []byte) (pcm []byte, sampleRate, channels int, ok bool)
- func ProviderNameFromProfileID(profileID string) string
- func ResolveDictationStreamOptions(provider, profileID string, opts speechkit.DictationStreamOptions, ...) speechkit.DictationStreamOptions
- func ToTranscript(r *Result, durationSecs float64) speechkit.Transcript
- type CapabilityReporter
- type ErrorKind
- type ExplicitOnlyProvider
- type ProviderError
- type ProviderSelectedObserver
- type ResolvedTranscribeOptions
- type Result
- type Router
- func (r *Router) AddCloud(p STTProvider)
- func (r *Router) AvailableProviders() []string
- func (r *Router) Cloud(name string) STTProvider
- func (r *Router) DictationBatchProvider(ctx context.Context, opts speechkit.DictationStreamOptions) (STTProvider, bool)
- func (r *Router) HasDictationStreaming() bool
- func (r *Router) HuggingFace() STTProvider
- func (r *Router) Local() STTProvider
- func (r *Router) PreferCloud(name string, p STTProvider)
- func (r *Router) Providers() []STTProvider
- func (r *Router) Route(ctx context.Context, audio []byte, audioDurationSecs float64, ...) (res *Result, err error)
- func (r *Router) SetCloud(name string, p STTProvider)
- func (r *Router) SetCloudProviders(providers []STTProvider)
- func (r *Router) SetHuggingFace(p STTProvider)
- func (r *Router) SetLocal(p STTProvider)
- func (r *Router) SetVPS(p STTProvider)
- func (r *Router) StartDictationStream(ctx context.Context, opts speechkit.DictationStreamOptions, ...) (speechkit.DictationStream, error)
- func (r *Router) StartSpeakerStream(ctx context.Context, opts speaker.Options, format speaker.AudioFormat) (speaker.SpeakerStream, error)
- func (r *Router) VPS() STTProvider
- type STTProvider
- type SecretResolver
- type Strategy
- type TranscribeOpts
- type TranscriberOption
- type WordConfidence
Constants ¶
const LanguageMulti = "multi"
LanguageMulti is the value SpeechKit carries when no language is pinned.
SpeechKit does not narrow speech to one language: a pinned language breaks switching language mid-conversation and speaking different languages with different people in one session, and it is a silent data-loss bug — the same English audio returns a zero-length transcript when pinned to German, with HTTP 200 and no error.
It is deliberately NOT forwarded verbatim. Each provider expresses multilanguage in its own dialect: Deepgram takes the literal "multi", AssemblyAI sets language_detection, and the OpenAI-compatible, local and OpenRouter adapters express it by omitting the field so the model auto-detects. Sending "multi" to any of the latter is an invalid value.
const MaxResponseBytes = 1 << 20
MaxResponseBytes bounds how much of a provider's HTTP response an adapter reads. Transcription responses are text; anything larger is a misconfiguration or a hostile endpoint, not a longer transcript.
Variables ¶
var ( // ErrAuth matches provider errors of [ErrorKindAuth]. ErrAuth = errors.New("stt: provider authentication failed") // ErrRateLimited matches provider errors of [ErrorKindRateLimit]. ErrRateLimited = errors.New("stt: provider rate limited") // ErrInvalidRequest matches provider errors of [ErrorKindInvalidRequest]. ErrInvalidRequest = errors.New("stt: provider rejected request") ErrProviderUnavailable = errors.New("stt: provider unavailable") )
Sentinel errors for use with errors.Is. A ProviderError matches the sentinel of its Kind.
Functions ¶
func ApplyResolvedDictationStreamOptions ¶ added in v0.76.2
func ApplyResolvedDictationStreamOptions(opts speechkit.DictationStreamOptions, resolved ResolvedTranscribeOptions) speechkit.DictationStreamOptions
ApplyResolvedDictationStreamOptions maps resolved recognition settings back onto a stream while preserving session, interim, format and profile metadata.
func AsTranscriber ¶ added in v0.61.28
func AsTranscriber(p STTProvider, opts ...TranscriberOption) speechkit.Transcriber
AsTranscriber adapts an STTProvider to the kernel's speechkit.Transcriber interface, so hosts can hand any provider straight to dictation.NewRuntime or a TranscriptionWorker without hand-writing the mechanical Result-to-Transcript adapter. The per-call language overrides the base option language when non-empty; when both are empty the request carries no language at all — the adapter never invents a default, because language selection (including multilanguage) is an explicit caller decision.
The device app keeps its own richer internal adapter (vocabulary bias, customization, routing); this bridge covers the plain provider-to-kernel path for library consumers.
func BaseCapabilities ¶ added in v0.64.3
func BaseCapabilities() []speechkit.Capability
BaseCapabilities are reported by every speech-to-text provider. A fresh slice is returned each call so callers may append without aliasing.
func ClassifyTransportError ¶ added in v0.74.0
ClassifyTransportError wraps a failure from performing the HTTP request itself. Deadline expiry and timeouts become ErrorKindTimeout, other network failures ErrorKindNetwork; both are retryable and keep err reachable through errors.Unwrap. Caller cancellation, nil and errors that are not transport failures are returned unchanged, so errors.Is(err, context.Canceled) keeps working.
func EnsureTranscriptionWAV ¶ added in v0.64.3
EnsureTranscriptionWAV wraps raw PCM in a WAV header when it does not already carry one, because every HTTP transcription endpoint expects a container rather than bare samples.
func EnvSecretResolver ¶ added in v0.67.14
EnvSecretResolver reads secrets from the process environment. It is the default every provider falls back to when no resolver is configured.
func FirstNonEmptyTrimmed ¶ added in v0.64.3
FirstNonEmptyTrimmed returns the first value that is not blank after trimming, or "". Provider adapters use it to layer a request override over a provider default over a package default.
func IsMultilanguage ¶ added in v0.53.0
IsMultilanguage reports whether language asks for multilanguage rather than a specific locale. Empty, "auto" and "multi" all mean the same thing: do not pin. The settings UI offers "auto" and "multi" as separate labels, so both have to resolve here or the literal token reaches providers that reject it.
func IsWebSocketClose ¶ added in v0.64.3
IsWebSocketClose reports whether err is a WebSocket close, as opposed to a transport failure. Streaming providers treat the two differently: a close is the end of a session, a transport failure is worth surfacing.
func MaxSpeakers ¶ added in v0.64.3
MaxSpeakers is the upper-bound counterpart of MinSpeakers.
func MinSpeakers ¶ added in v0.64.3
MinSpeakers and MaxSpeakers collapse the three speaker-count knobs into the single lower and upper bound a provider request carries. An exact expected count wins over the range.
func PCM16FromWAV ¶ added in v0.64.3
PCM16FromWAV extracts raw PCM16 sample data plus the sample rate and channel count from a LINEAR16 RIFF/WAVE byte slice. It returns ok=false when the input is not a 16-bit PCM WAV, in which case callers should treat the bytes as already-raw PCM and fall back to a default rate.
Providers that must declare the sample rate explicitly (e.g. Google STT v1 speech:recognize) rely on this to avoid sending a wrong hard-coded rate, which the provider rejects with HTTP 400 on a mismatch.
func ProviderNameFromProfileID ¶ added in v0.64.3
ProviderNameFromProfileID extracts the bare provider name from a model_selection profile id, or "" when the id names a specific model.
func ResolveDictationStreamOptions ¶ added in v0.76.2
func ResolveDictationStreamOptions(provider, profileID string, opts speechkit.DictationStreamOptions, defaults, overrides provideropts.Values) speechkit.DictationStreamOptions
ResolveDictationStreamOptions applies the batch option resolver to a native stream, retaining its session metadata. Concrete adapters supply their own defaults and overrides, just as they do for ResolveTranscribeOptions.
func ToTranscript ¶ added in v0.61.28
func ToTranscript(r *Result, durationSecs float64) speechkit.Transcript
ToTranscript maps a provider Result to a speechkit.Transcript. The mapping is mechanical: text, language, provider, model, confidence, per-word confidences, and speaker diarization pass through 1:1. Duration comes from the Result when the provider reported one; otherwise durationSecs (the caller-measured audio length) fills in. A nil Result yields a zero Transcript.
Types ¶
type CapabilityReporter ¶
type CapabilityReporter interface {
Capabilities() []speechkit.Capability
}
CapabilityReporter is an optional interface a provider can implement to self-describe its capabilities. Routing and catalogs can type-assert it to query capabilities directly instead of string-matching profile IDs.
It is intentionally NOT part of STTProvider, so existing providers, server clients, and test doubles continue to satisfy the core interface without change; only the production providers below opt in. Capabilities are reported using the public speechkit.Capability vocabulary so the adapters carry no internal/ dependency.
type ErrorKind ¶ added in v0.74.0
type ErrorKind string
ErrorKind classifies why an STT provider call failed, so embedders can decide between retrying, failing over, re-authenticating or surfacing the error without parsing messages.
const ( // ErrorKindAuth means the credentials were missing, invalid or not // permitted (HTTP 401/403). ErrorKindAuth ErrorKind = "auth" // ErrorKindRateLimit means the provider throttled the request (HTTP 429). ErrorKindRateLimit ErrorKind = "rate_limit" // ErrorKindInvalidRequest means the provider rejected the request itself; // retrying the same request will not help. ErrorKindInvalidRequest ErrorKind = "invalid_request" // (HTTP 5xx). ErrorKindUnavailable ErrorKind = "unavailable" // ErrorKindNetwork means the request never got a provider answer because // of a transport failure. ErrorKindNetwork ErrorKind = "network" // ErrorKindTimeout means the provider or the deadline ran out of time. ErrorKindTimeout ErrorKind = "timeout" // ErrorKindUnknown means the failure fits no other kind. ErrorKindUnknown ErrorKind = "unknown" )
Error kinds reported by ProviderError.
type ExplicitOnlyProvider ¶ added in v0.77.2
type ExplicitOnlyProvider interface {
ExplicitOnly() bool
}
ExplicitOnlyProvider is an optional interface for an opt-in provider that must never serve audio nobody directed at it. While ExplicitOnly reports true, a Router skips the provider in every generic selection and fallback loop (batch cloud routing, the dynamic strategy, the parallel race, realtime dictation and speaker streams) and uses it only for a request whose TranscribeOpts.ProviderProfileID (or stream equivalent) names it. A host that registers the provider because the user selected it reports false, and the provider then routes like any other cloud provider. A provider without this method is never explicit-only, so existing providers behave unchanged.
type ProviderError ¶ added in v0.74.0
type ProviderError struct {
// Provider is the provider name, for example "deepgram".
Provider string
// StatusCode is the HTTP status, or 0 for transport failures.
StatusCode int
// Kind classifies the failure.
Kind ErrorKind
// Retryable reports whether retrying the same request may succeed.
Retryable bool
// RetryAfter is the provider's requested back-off, or 0 when none was given.
RetryAfter time.Duration
// Message is a short, user-safe reason, truncated to 256 bytes.
Message string
// Err is the underlying cause, if any.
Err error
}
ProviderError is the typed failure of one STT provider call. It carries no audio and no credentials; Message is a short, user-safe reason.
func HTTPError ¶ added in v0.74.0
func HTTPError(provider string, resp *http.Response, body []byte) *ProviderError
HTTPError classifies a non-2xx provider response. resp supplies the status and Retry-After header (nil is tolerated); body is only inspected to derive a safe reason and is never copied into the error.
func (*ProviderError) Error ¶ added in v0.74.0
func (e *ProviderError) Error() string
Error implements error. It names the provider, the status and the safe reason, never raw response bodies.
func (*ProviderError) Is ¶ added in v0.74.0
func (e *ProviderError) Is(target error) bool
Is reports whether target is the sentinel for e's Kind.
func (*ProviderError) Unwrap ¶ added in v0.74.0
func (e *ProviderError) Unwrap() error
Unwrap returns the underlying cause.
type ProviderSelectedObserver ¶ added in v0.67.14
ProviderSelectedObserver is invoked after every successful routed transcription with the winning provider's name and the active strategy. Hosts use it to record audit events; the framework itself stays free of host logging dependencies. Observer failures must never abort a user-facing transcription, so the callback has no error return.
type ResolvedTranscribeOptions ¶
type ResolvedTranscribeOptions struct {
Language string
Model string
Prompt string
ContextPrompt string
LanguageHints []string
Keyterms []string
Speaker speaker.Options
DetectLanguage bool
Punctuation bool
SmartFormat bool
Dictation bool
FillerWords bool
Numerals bool
UseVocabularyKeyterms bool
Timestamps bool
EndpointingMs int
PrivacyRedaction bool
// NoStore asks the provider not to retain this request beyond answering
// it. Only providers whose manifest declares the option natively act on
// it; the rest report it as unsupported so a retention policy can refuse
// them instead of assuming.
NoStore bool
VoiceFocus bool
MedicalDomain bool
Effective provideropts.EffectiveOptions
}
ResolvedTranscribeOptions is the provider-neutral view of one transcription request after ResolveTranscribeOptions has layered every option source. The scalar fields hold the effective values (empty, false or zero when nothing set them); Model is the raw request override; Effective keeps every option with the source it came from, which ResolvedTranscribeOptions.APILanguage consults.
func ResolveTranscribeOptions ¶
func ResolveTranscribeOptions(provider, profileID string, opts TranscribeOpts, providerDefaults, providerOverrides provideropts.Values) ResolvedTranscribeOptions
ResolveTranscribeOptions resolves the options for one request against the provider's STT option manifest (an empty manifest when none is registered; profileID is only stamped on the result). Precedence, lowest to highest: providerDefaults, opts.Options, providerOverrides merged with opts.ProviderOptions, then opts.RequestOptions and the request's own Language, Prompt, Keyterms and diarization wish. Unsupported options are kept but reported at debug level; Prompt and Keyterms fall back to the raw request values when resolution leaves them empty.
func ResolveTranscribeOptionsWithManifest ¶ added in v0.76.3
func ResolveTranscribeOptionsWithManifest(manifest provideropts.ProviderOptionManifest, profileID string, opts TranscribeOpts, providerDefaults, providerOverrides provideropts.Values) ResolvedTranscribeOptions
ResolveTranscribeOptionsWithManifest resolves recognition settings using the adapter's definition for its concrete model and transport. Custom providers use this boundary without modifying built-in manifests or host code. Native serialization and provider limits remain the adapter's responsibility.
func (ResolvedTranscribeOptions) APILanguage ¶
func (r ResolvedTranscribeOptions) APILanguage() string
APILanguage returns the language to put on the wire, or "" to let the model detect it. It is empty when the language came only from the provider default or was never set, when DetectLanguage is on, or when the language is multilanguage (see IsMultilanguage); otherwise it is the trimmed locale. Each provider translates "" into its own auto-detect dialect.
type Result ¶
type Result struct {
Text string
Language string
Duration time.Duration
Provider string
Model string
Confidence float64 // If available from the provider
// Words carries per-word acoustic confidence when the provider exposes it.
// nil for providers without word-level confidence. Offsets are NOT tracked
// because downstream vocabulary/punctuation rewriting invalidates them;
// consumers match on the word text instead.
Words []WordConfidence
Speakers *speaker.DiarizationResult
}
Result holds the output of a transcription.
type Router ¶ added in v0.61.32
type Router struct {
Strategy Strategy
PreferLocalUnderSecs float64
ParallelCloud bool
ReplaceOnBetter bool
// ParallelTimeout bounds how long a parallel local+cloud race waits for a
// result. Zero means 15 seconds. The wait never outlives the caller's
// context deadline.
ParallelTimeout time.Duration
// LocalFallbackProfileID names the cloud profile a local-only route
// falls back to when the local engine fails or stalls. Empty keeps
// local-only strict (the policy pin, or no fallback chosen). The local
// attempt then gets its own deadline (localAttemptTimeout) so the
// fallback still has time before the caller's deadline.
LocalFallbackProfileID string
// ConnectivityProbe is the TCP address used to test internet connectivity.
// Defaults to "1.1.1.1:443" when empty.
ConnectivityProbe string
// OnProviderSelected, when set, is called after every successful routed
// transcription. It scopes audit reporting to this router instance.
OnProviderSelected ProviderSelectedObserver
// Logger receives this router's diagnostics. Nil falls back to
// slog.Default() at log time.
Logger *slog.Logger
// contains filtered or unexported fields
}
Router selects the best STTProvider based on audio length, availability, and config.
func (*Router) AddCloud ¶ added in v0.61.32
func (r *Router) AddCloud(p STTProvider)
AddCloud appends a cloud provider to the ordered list (thread-safe).
func (*Router) AvailableProviders ¶ added in v0.61.32
AvailableProviders returns the names of configured providers.
func (*Router) Cloud ¶ added in v0.61.32
func (r *Router) Cloud(name string) STTProvider
Cloud returns a cloud provider by name, or nil if not found.
func (*Router) DictationBatchProvider ¶ added in v0.76.6
func (r *Router) DictationBatchProvider(ctx context.Context, opts speechkit.DictationStreamOptions) (STTProvider, bool)
DictationBatchProvider resolves the same configured candidate/profile order as StartDictationStream without opening a transport. It returns a provider only when its known selected profile cannot stream a complete capture, so a finals-only host can transcribe that same provider's complete recording without an unnecessary live handshake. Unknown or complete-capture profiles retain normal startup; this is never a fallback after a provider failure.
func (*Router) HasDictationStreaming ¶ added in v0.61.32
HasDictationStreaming reports whether at least one configured provider (honoring the routing strategy) can serve provider-native realtime dictation. Server surfaces use this for capability discovery so clients can fall back to batch transcription without a doomed stream attempt.
func (*Router) HuggingFace ¶ added in v0.61.32
func (r *Router) HuggingFace() STTProvider
HuggingFace returns the HuggingFace cloud provider (backward-compatible convenience).
func (*Router) Local ¶ added in v0.61.32
func (r *Router) Local() STTProvider
Local returns the current local provider.
func (*Router) PreferCloud ¶ added in v0.61.32
func (r *Router) PreferCloud(name string, p STTProvider)
PreferCloud sets/replaces a cloud provider and moves it to the front so it becomes the next cloud provider used by routing, while keeping remaining providers as fallbacks.
func (*Router) Providers ¶ added in v0.61.32
func (r *Router) Providers() []STTProvider
Providers returns a snapshot of every configured provider: the local provider first (when set), then the cloud providers in routing order. Hosts use it to register health probes without re-deriving the provider set from config.
func (*Router) Route ¶ added in v0.61.32
func (r *Router) Route(ctx context.Context, audio []byte, audioDurationSecs float64, opts TranscribeOpts) (res *Result, err error)
Route selects the appropriate provider(s) and returns the transcription result.
func (*Router) SetCloud ¶ added in v0.61.32
func (r *Router) SetCloud(name string, p STTProvider)
SetCloud replaces a cloud provider by name, or appends if not found. Pass nil to remove the provider with that name.
func (*Router) SetCloudProviders ¶ added in v0.61.32
func (r *Router) SetCloudProviders(providers []STTProvider)
SetCloudProviders replaces the ordered cloud provider list.
func (*Router) SetHuggingFace ¶ added in v0.61.32
func (r *Router) SetHuggingFace(p STTProvider)
SetHuggingFace sets/replaces the HuggingFace cloud provider (backward-compatible convenience).
func (*Router) SetLocal ¶ added in v0.61.32
func (r *Router) SetLocal(p STTProvider)
SetLocal sets the local provider (thread-safe).
func (*Router) SetVPS ¶ added in v0.61.32
func (r *Router) SetVPS(p STTProvider)
SetVPS sets/replaces the VPS cloud provider (backward-compatible convenience).
func (*Router) StartDictationStream ¶ added in v0.61.32
func (r *Router) StartDictationStream(ctx context.Context, opts speechkit.DictationStreamOptions, format speaker.AudioFormat) (speechkit.DictationStream, error)
StartDictationStream selects the first configured provider that can perform provider-native realtime dictation. It never changes batch routing; callers choose this path explicitly per recording session.
func (*Router) StartSpeakerStream ¶ added in v0.61.32
func (r *Router) StartSpeakerStream(ctx context.Context, opts speaker.Options, format speaker.AudioFormat) (speaker.SpeakerStream, error)
StartSpeakerStream selects the first configured provider that can perform realtime speaker attribution. The stream is an add-on path and never changes the normal STT routing decision for Dictation/Assist.
func (*Router) VPS ¶ added in v0.61.32
func (r *Router) VPS() STTProvider
VPS returns the VPS cloud provider (backward-compatible convenience).
type STTProvider ¶
type STTProvider interface {
// Transcribe sends audio data to the STT backend and returns the transcription.
Transcribe(ctx context.Context, audio []byte, opts TranscribeOpts) (*Result, error)
// Name returns the provider identifier (e.g. "local", "vps", "huggingface").
Name() string
// Health checks if the provider is reachable and ready.
Health(ctx context.Context) error
}
STTProvider defines the interface for all speech-to-text backends.
It is the provider-facing contract (the SPI): implement it to add a backend, hand it to a Router for fallback and routing, and bridge it to the kernel's host-facing speechkit.Transcriber with AsTranscriber. Hosts consume Transcriber; providers implement STTProvider.
func PrioritizeProviderProfile ¶ added in v0.64.3
func PrioritizeProviderProfile(candidates []STTProvider, profileID string) []STTProvider
PrioritizeProviderProfile moves the providers matching profileID to the front of the candidate list, keeping the rest as fallbacks in their original order.
type SecretResolver ¶ added in v0.67.14
SecretResolver resolves a named secret (typically an environment-variable name) to its value. An empty string means "not set".
Providers that read credentials lazily (for example the Google streaming adapter, which loads service-account JSON on first stream) expose a SecretResolver field so each provider instance can be bound to its own secret backend. That keeps two SpeechKit runtimes in one process — a test harness, a multi-tenant server — independent of each other. There is no process-wide resolver: hosts bind secrets per provider (or through allproviders.EnabledProviders.Secrets).
func (SecretResolver) Resolve ¶ added in v0.67.14
func (r SecretResolver) Resolve(name string) string
Resolve returns r(name). A nil resolver reads the process environment, so provider packages can call it on a zero-value field.
type Strategy ¶ added in v0.61.32
type Strategy string
Strategy defines the routing strategy.
const ( // StrategyDynamic prefers the local provider for audio shorter than // PreferLocalUnderSecs and the cloud providers otherwise, each falling // back to the other; a failed connectivity probe flips the preference to // local. StrategyDynamic Strategy = "dynamic" // StrategyLocalOnly uses the local provider alone. StrategyLocalOnly Strategy = "local-only" // StrategyCloudOnly uses the ordered cloud providers alone. StrategyCloudOnly Strategy = "cloud-only" )
Routing strategies. An empty Strategy behaves as StrategyDynamic.
type TranscribeOpts ¶
type TranscribeOpts struct {
// VocabularyHints holds dictionary-derived bias; explicit hints remain separate.
// ResolveTranscribeOptions honors vocabulary_bias opt-outs in every option layer.
VocabularyHints customize.RecognitionHints
Language string // "de", "en", "auto"; request override only
Model string // Optional: model override
Prompt string // Optional: provider-specific hint prompt for better recognition
Keyterms []string // Optional: provider-native vocabulary bias terms
// ConversationContext carries the preceding dialogue turns (oldest
// first, no speaker labels) for providers whose models condition on
// conversational context — e.g. AssemblyAI Universal-3.5 Pro sync
// accepts up to 100 turns / 4096 chars via conversation_context.
// Distinct from Prompt (which describes the domain/scenario) and
// Keyterms (explicit vocabulary). Providers without native support
// ignore it.
ConversationContext []string
// ProviderProfileID prioritizes a provider for this request. Accepts a
// full provider-profile ID (e.g. "stt.deepgram.nova-3") or a bare
// provider ID (e.g. "deepgram"); routers move matching providers to the
// front of their candidate list while keeping the remaining providers as
// fallbacks. An unknown or unconfigured value changes nothing — a
// request never hard-fails on an unsatisfiable preference. Mirrors
// speechkit.DictationStreamOptions.ProviderProfileID for the batch path.
ProviderProfileID string
Speaker speaker.Options // Optional speaker diarization / attribution request
RequestOptions provideropts.Values // Optional explicit request options; highest precedence
Options provideropts.Values // Optional normalized global/default voice options
ProviderOptions provideropts.Values // Optional normalized overrides for the selected provider
ProviderOptionsByProvider map[string]provideropts.Values // Optional provider-keyed overrides used by routers
}
TranscribeOpts configures a single transcription request.
func TranscribeOptionsFromStream ¶ added in v0.76.2
func TranscribeOptionsFromStream(o speechkit.DictationStreamOptions) TranscribeOpts
TranscribeOptionsFromStream returns the shared recognition option sources. Stream session metadata remains on the original DictationStreamOptions.
func (TranscribeOpts) DictationStreamOptions ¶ added in v0.76.2
func (o TranscribeOpts) DictationStreamOptions(base speechkit.DictationStreamOptions) speechkit.DictationStreamOptions
DictationStreamOptions carries the same recognition settings into a native stream. base supplies stream metadata and explicit request overrides; nonzero base values win. Dictionary hints remain separate until the adapter resolves its provider defaults and overrides, including vocabulary opt-outs.
func (TranscribeOpts) ForProvider ¶
func (o TranscribeOpts) ForProvider(provider string) TranscribeOpts
ForProvider returns a copy of o whose ProviderOptions are a clone of the original merged with the ProviderOptionsByProvider entry for provider (matched case-insensitively). Routers call it for the provider they picked so per-provider tuning applies without the caller knowing which one won.
func (TranscribeOpts) WithVocabulary ¶ added in v0.76.2
func (o TranscribeOpts) WithVocabulary(words []customize.Word) TranscribeOpts
WithVocabulary returns a copy of o with dictionary hints rendered by the public customization contract. Explicit Prompt/Keyterms and option overrides retain their precedence; a vocabulary_bias opt-out suppresses the derived hints.
type TranscriberOption ¶ added in v0.61.28
type TranscriberOption func(*transcriberOptions)
TranscriberOption configures the adapter returned by AsTranscriber.
func WithTranscribeOpts ¶ added in v0.61.28
func WithTranscribeOpts(base TranscribeOpts) TranscriberOption
WithTranscribeOpts sets the base TranscribeOpts applied to every request the adapter makes (prompt, keyterms, provider options, and so on). The Language field of the base is used only when the per-call language passed to Transcribe is empty; a non-empty per-call language always wins.
type WordConfidence ¶
type WordConfidence = speechkit.WordConfidence
WordConfidence is a single recognized word with the provider's per-word acoustic confidence in [0,1]. It is populated only by providers that expose word-level confidence (Deepgram, AssemblyAI); it stays nil for providers that do not (Google v1, OpenAI/Groq/HuggingFace Whisper, local whisper.cpp). Confidence here is acoustic (how sure the model is it heard this word), not semantic — a low value flags a likely mis-recognition or dropped word.
It is an alias of the kernel type so provider results and Transcripts share one word type; hosts never convert between the two.