provideropts

package
v0.81.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 4 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package provideropts defines SpeechKit's provider-neutral voice option vocabulary and the manifest/resolve types used by concrete provider adapters.

Stability: Stable — no breaking change without a minor version bump and a changelog callout.

Index

Constants

View Source
const (
	// SchemaProviderOptions is the schema identifier of the manifest format,
	// echoed by the catalog API.
	SchemaProviderOptions = "speechkit.provider_options.v1"
	// ManifestUpdated is the date (YYYY-MM-DD) the built-in manifests were
	// last audited against vendor documentation.
	ManifestUpdated = "2026-09-30"

	// Modalities a manifest describes; [FindManifest] keys on them.
	ModalitySTT        = "stt"
	ModalityTTS        = "tts"
	ModalityVoiceAgent = "voice_agent"
)

Metadata stamped on every built-in manifest.

Variables

View Source
var (
	DeepgramKeytermLimits   = KeytermLimits{MaxTerms: 100, TokenBudget: 450}
	AssemblyAIKeytermLimits = KeytermLimits{MaxTerms: 100, MaxChars: 50}
	XAIKeytermLimits        = KeytermLimits{MaxTerms: 100, MaxChars: 50}
)

Documented keyterm bounds of the hosted providers. Past Deepgram's limit of 500 tokens Listen and the Voice Agent reject the whole request, so its budget stays below it; AssemblyAI accepts at most 100 terms of 50 characters.

Functions

func CapKeyterms added in v0.79.15

func CapKeyterms(terms []string, limits KeytermLimits) []string

CapKeyterms returns terms in order, trimmed, de-duplicated case-insensitively and within limits.

func KeytermTokenEstimate added in v0.79.15

func KeytermTokenEstimate(term string) int

KeytermTokenEstimate over-estimates the tokens a provider counts for one keyterm. Measured against Deepgram (2026-11-02): short terms cost about 7 tokens and longer ones about 4 plus 0.4 per character, so the estimate is at least 8 and 4 plus half a token per character.

func ManifestsByProvider

func ManifestsByProvider() map[string][]ProviderOptionManifest

ManifestsByProvider groups DefaultManifests by provider identifier; a provider that serves several modalities has one entry per modality.

Types

type EffectiveOption

type EffectiveOption struct {
	ID      OptionID      `json:"id"`
	Value   any           `json:"value,omitempty"`
	Source  ValueSource   `json:"source"`
	Support OptionSupport `json:"support"`
}

EffectiveOption is one resolved option: the winning Value, the layer it came from, and the provider's support row for it.

type EffectiveOptions

type EffectiveOptions struct {
	Provider    string                       `json:"provider"`
	Modality    string                       `json:"modality"`
	ProfileID   string                       `json:"profileId,omitempty"`
	Options     map[OptionID]EffectiveOption `json:"options"`
	Unsupported []UnsupportedOptionReport    `json:"unsupported,omitempty"`
}

EffectiveOptions is the result of Resolve for one provider and modality: every option seen in the manifest or any input layer, plus reports for explicitly configured options the provider cannot honor.

func Resolve

func Resolve(input ResolveInput) EffectiveOptions

Resolve merges the layers of input into one EffectiveOptions. For each option the highest-precedence layer that has it wins; options absent from the manifest count as unsupported and are reported when explicitly configured to a non-zero value. Options are processed in sorted ID order so the Unsupported list is deterministic.

func (EffectiveOptions) Bool

func (e EffectiveOptions) Bool(id OptionID) bool

Bool returns the resolved bool for id, or false when absent or not a bool.

func (EffectiveOptions) Float

func (e EffectiveOptions) Float(id OptionID) float64

Float returns the resolved value for id as a float64, accepting float64, float32, int, int32, and int64; it returns 0 when absent or of another type.

func (EffectiveOptions) Int

func (e EffectiveOptions) Int(id OptionID) int

Int returns the resolved value for id as an int, accepting int, int32, int64, and float64 (truncated); it returns 0 when absent or of another type.

func (EffectiveOptions) String

func (e EffectiveOptions) String(id OptionID) string

String returns the trimmed resolved string for id, or "" when absent or not a string.

func (EffectiveOptions) StringList

func (e EffectiveOptions) StringList(id OptionID) []string

StringList returns the resolved value for id with the same coercion rules as Values.StringList, or nil when absent.

func (EffectiveOptions) Value

func (e EffectiveOptions) Value(id OptionID) any

Value returns the raw resolved value for id, or nil when the option was not resolved.

type KeytermLimits added in v0.79.15

type KeytermLimits struct {
	// MaxTerms caps the number of terms.
	MaxTerms int
	// MaxChars drops (never truncates) a term longer than this many runes.
	MaxChars int
	// TokenBudget caps the estimated tokens across all terms
	// ([KeytermTokenEstimate]); a term that no longer fits is skipped.
	TokenBudget int
}

KeytermLimits bounds what one provider's keyterm field accepts. A zero field means "no bound of that kind".

type OptionDefinition

type OptionDefinition struct {
	ID          OptionID   `json:"id"`
	Label       string     `json:"label"`
	Description string     `json:"description,omitempty"`
	Type        OptionType `json:"type"`
	Advanced    bool       `json:"advanced,omitempty"`
}

OptionDefinition is the UI-facing description of an option: its value Type plus a Label and Description; Advanced hides it from basic settings surfaces.

type OptionID

type OptionID string

OptionID names one provider-neutral voice option. A ProviderOptionManifest says how each provider adapter honors it.

const (
	// OptionLanguage is the recognition or synthesis language (BCP-47).
	OptionLanguage OptionID = "language"
	// OptionDetectLanguage asks the provider to detect the spoken language.
	OptionDetectLanguage OptionID = "detect_language"
	// OptionPunctuation enables automatic punctuation.
	OptionPunctuation OptionID = "punctuation"
	// OptionSmartFormat enables provider text formatting of dates, numbers,
	// and similar entities.
	OptionSmartFormat OptionID = "smart_format"
	// OptionDictation turns spoken punctuation commands into punctuation.
	OptionDictation OptionID = "dictation"
	// OptionFillerWords keeps filler words such as "um" in the transcript.
	OptionFillerWords OptionID = "filler_words"
	// OptionNumerals writes spoken numbers as digits.
	OptionNumerals OptionID = "numerals"
	// OptionVocabularyBias sends the resolved Words as provider vocabulary
	// hints.
	OptionVocabularyBias OptionID = "vocabulary_bias"
	// OptionKeyterms is a static list of terms to boost.
	OptionKeyterms OptionID = "keyterms"
	// OptionPromptHint is free-text prompt context for Whisper-style STT.
	OptionPromptHint OptionID = "prompt_hint"
	// OptionSpeakerDiarization labels speakers in the transcript.
	OptionSpeakerDiarization OptionID = "speaker_diarization"
	// OptionTimestamps requests word-level timing.
	OptionTimestamps OptionID = "timestamps"
	// OptionEndpointingMs is the silence, in milliseconds, that ends an
	// utterance or turn.
	OptionEndpointingMs OptionID = "endpointing_ms"
	// OptionTurnDetection enables server-side turn detection; some providers
	// take a confidence threshold instead of a bool.
	OptionTurnDetection OptionID = "turn_detection"
	// OptionVoice selects the TTS voice or speak model.
	OptionVoice OptionID = "voice"
	// OptionSpeed is the TTS speaking rate.
	OptionSpeed OptionID = "speed"
	// OptionAudioFormat selects the TTS output encoding or container.
	OptionAudioFormat OptionID = "audio_format"
	// OptionContextPrompt is the system or context prompt of a streaming STT
	// or Voice Agent session.
	OptionContextPrompt OptionID = "context_prompt"
	// OptionLanguageHints lists likely languages for multilingual sessions.
	OptionLanguageHints OptionID = "language_hints"
	// OptionPrivacyRedaction redacts personal information from transcripts.
	OptionPrivacyRedaction OptionID = "privacy_redaction"
	// OptionVoiceFocus suppresses background noise so recognition follows the
	// primary speaker.
	OptionVoiceFocus OptionID = "voice_focus"
	// OptionMedicalDomain routes to a medical-domain model.
	OptionMedicalDomain OptionID = "medical_domain"
	// OptionReasoningEffort sets the Voice Agent model's reasoning effort.
	OptionReasoningEffort OptionID = "reasoning_effort"
	// OptionTranslation enables realtime translation.
	OptionTranslation OptionID = "translation"
	// OptionTranscriptionOnly runs a Voice Agent session as transcription
	// without agent responses.
	OptionTranscriptionOnly OptionID = "transcription_only"
	// OptionResume resumes an interrupted Voice Agent session.
	OptionResume OptionID = "resume"
	// OptionNoStore asks the provider not to retain the request content
	// beyond the time it takes to answer, and not to train on it. What that
	// costs differs per vendor: a query parameter for some, an account or
	// project setting for others, and nothing at all for a local runtime.
	// The manifest says which, so a retention policy can refuse a provider
	// that cannot assert it rather than promising something untrue.
	OptionNoStore OptionID = "no_store"
)

Provider-neutral option identifiers. The same ID may back a different native parameter, or none at all, in each provider manifest.

type OptionSupport

type OptionSupport struct {
	ID          OptionID         `json:"id"`
	Status      SupportStatus    `json:"status"`
	NativeKey   string           `json:"nativeKey,omitempty"`
	Implemented bool             `json:"implemented"`
	EvidenceURL string           `json:"evidenceUrl,omitempty"`
	Notes       string           `json:"notes,omitempty"`
	Definition  OptionDefinition `json:"definition"`
}

OptionSupport is one manifest row: how a provider adapter treats one option. NativeKey names the provider parameter for native support, Implemented says whether the adapter actually wires it, EvidenceURL points at the vendor documentation the status was verified against, and Notes carries caveats such as how multilanguage is expressed.

type OptionType

type OptionType string

OptionType is the value type an option carries in Values.

const (
	TypeString     OptionType = "string"
	TypeBool       OptionType = "bool"
	TypeInt        OptionType = "int"
	TypeFloat      OptionType = "float"
	TypeStringList OptionType = "string_list"
)

Option value types. The accessors on Values and EffectiveOptions coerce loosely typed values (JSON numbers, []any) to these shapes.

type ProviderOptionManifest

type ProviderOptionManifest struct {
	Schema     string          `json:"schema"`
	Updated    string          `json:"updated"`
	Provider   string          `json:"provider"`
	Label      string          `json:"label"`
	Modality   string          `json:"modality"`
	ProfileIDs []string        `json:"profileIds,omitempty"`
	Options    []OptionSupport `json:"options"`
}

ProviderOptionManifest declares, for one provider adapter and modality, how every option is supported. ProfileIDs lists the catalog profiles the manifest covers; Schema and Updated carry SchemaProviderOptions and ManifestUpdated.

func DefaultManifests

func DefaultManifests() []ProviderOptionManifest

DefaultManifests returns the built-in option manifests SpeechKit registers for its STT, TTS, and Voice Agent adapters, one per provider and modality. Each call builds a fresh slice.

func FindManifest

func FindManifest(provider, modality string) (ProviderOptionManifest, bool)

FindManifest returns the built-in manifest for the adapter identifier provider and modality (one of the Modality constants). The boolean is false when no manifest describes that pair.

func LocalParakeetSTTManifest added in v0.77.15

func LocalParakeetSTTManifest() ProviderOptionManifest

LocalParakeetSTTManifest describes the built-in local provider when its model is a sherpa-onnx Parakeet directory served by speechkit-stt-sherpa. It shares the provider id "local" with [localSTTManifest] (one local runtime runs at a time), so it is not in DefaultManifests; the local provider resolves Parakeet requests against it directly.

func OpenAICompatibleSTTManifest added in v0.76.3

func OpenAICompatibleSTTManifest(provider string) ProviderOptionManifest

OpenAICompatibleSTTManifest describes the shipped generic multipart adapter's language and prompt serialization under a host's provider identity. It does not assert native keyword support; concrete models may supply their own definition to ResolveTranscribeOptionsWithManifest.

func (ProviderOptionManifest) RecognitionBiasOption added in v0.76.3

func (m ProviderOptionManifest) RecognitionBiasOption() OptionID

RecognitionBiasOption selects the implemented channel for dictionary hints. Keyterms take precedence over transcript-style prompts. Unsupported, unimplemented and provider-default rows cannot carry request hints. Adapters may supply a manifest for their concrete model and transport.

func (ProviderOptionManifest) SupportByID

func (m ProviderOptionManifest) SupportByID() map[OptionID]OptionSupport

SupportByID indexes the manifest's Options by OptionID; a later duplicate row replaces an earlier one.

type ResolveInput

type ResolveInput struct {
	Manifest          ProviderOptionManifest
	ProfileID         string
	ProviderDefaults  Values
	GlobalDefaults    Values
	ProviderOverrides Values
	RequestOverrides  Values
}

ResolveInput carries the manifest and the four value layers Resolve merges, lowest precedence first: ProviderDefaults, GlobalDefaults, ProviderOverrides, RequestOverrides. ProfileID is echoed into the result.

type SupportStatus

type SupportStatus string

SupportStatus says how a provider adapter honors an option.

const (
	// SupportNative maps to a real provider parameter, named by
	// [OptionSupport].NativeKey.
	SupportNative SupportStatus = "native"
	// SupportEmulated is reproduced by SpeechKit's own runtime because the
	// provider has no switch for it.
	SupportEmulated SupportStatus = "emulated"
	// SupportDerived is honored indirectly, for example by omitting the
	// language field or rendering terms into a prompt; Notes say how.
	SupportDerived SupportStatus = "derived"
	// SupportUnsupported cannot be asserted on a request; an explicitly
	// configured value is reported in [EffectiveOptions].Unsupported.
	SupportUnsupported SupportStatus = "unsupported"
	// SupportProviderDefault is already satisfied by the provider without
	// being asked, so SpeechKit sends nothing.
	SupportProviderDefault SupportStatus = "provider_default"
)

Support statuses recorded in a manifest row.

type UnsupportedOptionReport

type UnsupportedOptionReport struct {
	ID        OptionID    `json:"id"`
	Source    ValueSource `json:"source"`
	Value     any         `json:"value,omitempty"`
	Provider  string      `json:"provider"`
	Modality  string      `json:"modality"`
	ProfileID string      `json:"profileId,omitempty"`
	Reason    string      `json:"reason"`
}

UnsupportedOptionReport explains why a configured option will not reach the provider: it was set explicitly (not unset or a provider default), is non-zero, and the manifest marks it SupportUnsupported.

type ValueSource

type ValueSource string

ValueSource records which configuration layer supplied an effective option value.

const (
	// SourceUnset means no layer set the option.
	SourceUnset ValueSource = "unset"
	// SourceProviderDefault is the adapter's built-in default.
	SourceProviderDefault ValueSource = "provider_default"
	// SourceGlobalDefault is the host's provider-independent setting.
	SourceGlobalDefault ValueSource = "global"
	// SourceProviderOverride is the host's per-provider setting.
	SourceProviderOverride ValueSource = "provider_override"
	// SourceRequestOverride was passed with the individual request.
	SourceRequestOverride ValueSource = "request_override"
)

Value sources. Resolve takes the first layer that has the option in the order request override, provider override, global default, provider default.

type Values

type Values map[OptionID]any

Values is one layer of option values keyed by OptionID. Values are loosely typed (bool, string, numbers, []string, or []any from JSON); the typed accessors coerce them. A nil Values is safe to read.

func (Values) Bool

func (v Values) Bool(id OptionID) bool

Bool returns the bool value for id, or false when the option is absent or not a bool.

func (Values) Clone

func (v Values) Clone() Values

Clone returns a deep copy of v (slice values are copied), or nil when v is empty.

func (Values) Float

func (v Values) Float(id OptionID) float64

Float returns the value for id as a float64, accepting float64, float32, and int; it returns 0 when absent or of another type.

func (Values) Get

func (v Values) Get(id OptionID) any

Get returns the raw value stored for id, or nil when absent.

func (Values) Has

func (v Values) Has(id OptionID) bool

Has reports whether id is present in v, even when its value is nil.

func (Values) Int

func (v Values) Int(id OptionID) int

Int returns the value for id as an int, accepting int, int32, int64, and float64 (truncated); it returns 0 when absent or of another type.

func (Values) Merge

func (v Values) Merge(other Values) Values

Merge copies every entry of other into v, overwriting existing keys, and returns the result. It mutates v in place unless v is nil, in which case a new map is returned; an empty other returns v unchanged.

func (Values) String

func (v Values) String(id OptionID) string

String returns the trimmed string value for id, or "" when the option is absent or not a string.

func (Values) StringList

func (v Values) StringList(id OptionID) []string

StringList returns the value for id as a trimmed list de-duplicated case-insensitively. It accepts []string, []any of strings, or a single string split on commas, semicolons, and newlines, and returns nil when absent or empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL