customize

package
v0.48.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package customize defines SpeechKit's public Words/Replacements contract.

Index

Constants

View Source
const PackSchemaVersion = "speechkit.customization.pack.v1"

Variables

This section is empty.

Functions

func NormalizeLanguage

func NormalizeLanguage(language string) string

func StableID

func StableID(prefix string, parts ...string) string

func ValidatePack

func ValidatePack(pack Pack) error

func ValidateReplacement

func ValidateReplacement(replacement Replacement) error

func ValidateWord

func ValidateWord(word Word) error

Types

type Context

type Context struct {
	Mode              Mode       `json:"mode,omitempty"`
	Language          string     `json:"language,omitempty"`
	Stage             Stage      `json:"stage,omitempty"`
	Tags              []string   `json:"tags,omitempty"`
	Persona           string     `json:"persona,omitempty"`
	ActiveTemplateIDs []string   `json:"active_template_ids,omitempty"`
	ScopeOrder        []ScopeRef `json:"scope_order,omitempty"`
}

type Kind

type Kind string
const (
	KindSubstitution Kind = "substitution"
	KindSynonym      Kind = "synonym"
	KindSnippet      Kind = "snippet"
	KindCommand      Kind = "command"
	KindTemplate     Kind = "template"
)

func NormalizeKind

func NormalizeKind(kind Kind) Kind

type Lexicon

type Lexicon struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description,omitempty"`
	Language    string    `json:"language,omitempty"`
	WordIDs     []string  `json:"word_ids,omitempty"`
	Tags        []string  `json:"tags,omitempty"`
	Source      string    `json:"source,omitempty"`
	Scope       *ScopeRef `json:"scope,omitempty"`
	Enabled     bool      `json:"enabled"`
	CreatedAt   time.Time `json:"created_at,omitempty"`
	UpdatedAt   time.Time `json:"updated_at,omitempty"`
}

type ListOptions

type ListOptions struct {
	Language        string
	Mode            Mode
	Stage           Stage
	IncludeDisabled bool
	Source          string
	Tags            []string
}

type Match

type Match struct {
	Type          MatchType `json:"type"`
	Pattern       string    `json:"pattern"`
	CaseSensitive bool      `json:"case_sensitive,omitempty"`
	WordBoundary  bool      `json:"word_boundary,omitempty"`
}

type MatchType

type MatchType string
const (
	MatchLiteral     MatchType = "literal"
	MatchPhrase      MatchType = "phrase"
	MatchRegex       MatchType = "regex"
	MatchSpokenAlias MatchType = "spoken_alias"
)

func NormalizeMatchType

func NormalizeMatchType(matchType MatchType) MatchType

type Mode

type Mode string
const (
	ModeDictation  Mode = "dictation"
	ModeAssist     Mode = "assist"
	ModeVoiceAgent Mode = "voice_agent"
)

func NormalizeMode

func NormalizeMode(mode Mode) Mode

type Pack

type Pack struct {
	SchemaVersion string          `json:"schema_version"`
	ID            string          `json:"id,omitempty"`
	Name          string          `json:"name,omitempty"`
	Description   string          `json:"description,omitempty"`
	Words         []Word          `json:"words,omitempty"`
	Replacements  []Replacement   `json:"replacements,omitempty"`
	Lexicons      []Lexicon       `json:"lexicons,omitempty"`
	Rulesets      []Ruleset       `json:"rulesets,omitempty"`
	Attachments   json.RawMessage `json:"attachments,omitempty"`
	CreatedAt     time.Time       `json:"created_at,omitempty"`
}

type ReplaceOptions

type ReplaceOptions struct {
	Language string
	Source   string
}

type Replacement

type Replacement struct {
	ID         string            `json:"id"`
	Kind       Kind              `json:"kind"`
	Match      Match             `json:"match"`
	Output     ReplacementOutput `json:"output"`
	Language   string            `json:"language,omitempty"`
	Modes      []Mode            `json:"modes,omitempty"`
	Stage      Stage             `json:"stage"`
	Priority   int               `json:"priority,omitempty"`
	Tags       []string          `json:"tags,omitempty"`
	Source     string            `json:"source,omitempty"`
	Scope      *ScopeRef         `json:"scope,omitempty"`
	Enabled    bool              `json:"enabled"`
	UsageCount int               `json:"usage_count,omitempty"`
	CreatedAt  time.Time         `json:"created_at,omitempty"`
	UpdatedAt  time.Time         `json:"updated_at,omitempty"`
}

func WithDefaultsReplacement

func WithDefaultsReplacement(replacement Replacement) Replacement

type ReplacementOutput

type ReplacementOutput struct {
	Text     string         `json:"text,omitempty"`
	Intent   string         `json:"intent,omitempty"`
	Template string         `json:"template,omitempty"`
	Payload  map[string]any `json:"payload,omitempty"`
}

type Ruleset

type Ruleset struct {
	ID             string    `json:"id"`
	Name           string    `json:"name"`
	Description    string    `json:"description,omitempty"`
	Language       string    `json:"language,omitempty"`
	ReplacementIDs []string  `json:"replacement_ids,omitempty"`
	Tags           []string  `json:"tags,omitempty"`
	Source         string    `json:"source,omitempty"`
	Scope          *ScopeRef `json:"scope,omitempty"`
	Enabled        bool      `json:"enabled"`
	CreatedAt      time.Time `json:"created_at,omitempty"`
	UpdatedAt      time.Time `json:"updated_at,omitempty"`
}

type ScopeKind

type ScopeKind string
const (
	ScopeBuiltin   ScopeKind = "builtin"
	ScopeApp       ScopeKind = "app"
	ScopeInstall   ScopeKind = "install"
	ScopeOrg       ScopeKind = "org"
	ScopeWorkspace ScopeKind = "workspace"
	ScopeUser      ScopeKind = "user"
	ScopeSession   ScopeKind = "session"
)

func NormalizeScopeKind

func NormalizeScopeKind(kind ScopeKind) ScopeKind

type ScopeRef

type ScopeRef struct {
	Kind ScopeKind `json:"kind"`
	Key  string    `json:"key,omitempty"`
}

func DefaultDeviceScopeOrder

func DefaultDeviceScopeOrder() []ScopeRef

func DefaultServerScopeOrder

func DefaultServerScopeOrder() []ScopeRef

func NormalizeScopeRef

func NormalizeScopeRef(ref ScopeRef) ScopeRef

type Stage

type Stage string
const (
	StagePreRecognitionCleanup Stage = "pre_recognition_cleanup"
	StagePostSTT               Stage = "post_stt"
	StagePostLLM               Stage = "post_llm"
	StageOutput                Stage = "output"
)

func NormalizeStage

func NormalizeStage(stage Stage) Stage

type Word

type Word struct {
	ID         string    `json:"id"`
	Term       string    `json:"term"`
	SoundsLike []string  `json:"sounds_like,omitempty"`
	Language   string    `json:"language,omitempty"`
	Weight     float64   `json:"weight,omitempty"`
	Tags       []string  `json:"tags,omitempty"`
	Scope      *ScopeRef `json:"scope,omitempty"`
	Source     string    `json:"source,omitempty"`
	Enabled    bool      `json:"enabled"`
	UsageCount int       `json:"usage_count,omitempty"`
	CreatedAt  time.Time `json:"created_at,omitempty"`
	UpdatedAt  time.Time `json:"updated_at,omitempty"`
}

func WithDefaultsWord

func WithDefaultsWord(word Word) Word

Jump to

Keyboard shortcuts

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