Documentation
¶
Overview ¶
Package client provides a typed HTTP client for talking to a remote SpeechKit Server (the `app/cmd/speechkit-server` Linux container or any compatible deployment).
Use it from any Go program — desktop, server, or test harness — that wants to consume Dictation, Assist, or Voice Agent endpoints over the network without embedding the kernel.
Auth ¶
The client supports the same bearer-token flow as the server: pass the token via Options.Token (or the equivalent env var documented for the server you are calling). For local trusted setups, the server may be configured without a token; the client tolerates that mode.
Timeouts and retries ¶
Per-request timeouts are configured via Options.Timeout. The client does not retry by default — host apps own the retry policy because the right behavior differs between idempotent reads (safe to retry) and non-idempotent writes (which may need a higher-level dedupe key).
Stability: Beta — API-checked; may change with a changelog callout.
Index ¶
- type AudioAsset
- type CatalogReadiness
- type Client
- func (c *Client) CatalogContracts(ctx context.Context) ([]framework.ModeContract, error)
- func (c *Client) CatalogProfiles(ctx context.Context, mode string) ([]framework.ProviderProfile, error)
- func (c *Client) CatalogProviders(ctx context.Context) ([]catalog.ProviderMatrixRow, []catalog.ProviderDefault, error)
- func (c *Client) CatalogReadiness(ctx context.Context) ([]CatalogReadiness, error)
- func (c *Client) Config(ctx context.Context) (map[string]any, error)
- func (c *Client) CreatePersona(ctx context.Context, payload any) (json.RawMessage, error)
- func (c *Client) CreateRole(ctx context.Context, payload any) (json.RawMessage, error)
- func (c *Client) CreateSequence(ctx context.Context, payload any) (json.RawMessage, error)
- func (c *Client) CreateVoiceAgentSession(ctx context.Context) (*VoiceAgentTicket, error)
- func (c *Client) CreateVoiceAgentSessionWithOptions(ctx context.Context, options VoiceAgentSessionOptions) (*VoiceAgentTicket, error)
- func (c *Client) CustomizationPack(ctx context.Context, language string) (*Pack, error)
- func (c *Client) DeletePersona(ctx context.Context, id string) error
- func (c *Client) DeleteRole(ctx context.Context, id string) error
- func (c *Client) DeleteSequence(ctx context.Context, id string) error
- func (c *Client) DeleteVoiceAgentSession(ctx context.Context, sessionID string) error
- func (c *Client) DialVoiceAgent(ctx context.Context, ticket *VoiceAgentTicket) (*VoiceAgentSession, error)
- func (c *Client) DoJSON(ctx context.Context, method, path string, body, out any) error
- func (c *Client) ImportCustomizationPack(ctx context.Context, pack Pack) error
- func (c *Client) Lexicons(ctx context.Context, language string) ([]Lexicon, error)
- func (c *Client) Persona(ctx context.Context, id string) (json.RawMessage, error)
- func (c *Client) Personas(ctx context.Context) (json.RawMessage, error)
- func (c *Client) PersonasList(ctx context.Context) (json.RawMessage, error)
- func (c *Client) ProviderReadiness(ctx context.Context, id string) (*CatalogReadiness, error)
- func (c *Client) RawJSON(ctx context.Context, method, path string, body any) (json.RawMessage, error)
- func (c *Client) ReplaceLexicons(ctx context.Context, language string, lexicons []Lexicon) ([]Lexicon, error)
- func (c *Client) ReplaceReplacements(ctx context.Context, language string, replacements []Replacement) ([]Replacement, error)
- func (c *Client) ReplaceRulesets(ctx context.Context, language string, rulesets []Ruleset) ([]Ruleset, error)
- func (c *Client) ReplaceVocabularyEntries(ctx context.Context, language string, entries []DictionaryEntry) ([]DictionaryEntry, error)
- func (c *Client) ReplaceWords(ctx context.Context, language string, words []Word) ([]Word, error)
- func (c *Client) Replacements(ctx context.Context, language string) ([]Replacement, error)
- func (c *Client) Role(ctx context.Context, id string) (json.RawMessage, error)
- func (c *Client) Roles(ctx context.Context) (json.RawMessage, error)
- func (c *Client) Rulesets(ctx context.Context, language string) ([]Ruleset, error)
- func (c *Client) Sequence(ctx context.Context, id string) (json.RawMessage, error)
- func (c *Client) Sequences(ctx context.Context) (json.RawMessage, error)
- func (c *Client) Status(ctx context.Context) (*Status, error)
- func (c *Client) TTSSynthesize(ctx context.Context, input TTSSynthesizeRequest) (*TTSSynthesizeResponse, error)
- func (c *Client) TTSVoices(ctx context.Context) ([]Voice, error)
- func (c *Client) TranscribeFile(ctx context.Context, path string, opts TranscribeOptions) (*TranscribeResponse, error)
- func (c *Client) Transcript(ctx context.Context, id int64) (*Transcript, error)
- func (c *Client) Transcripts(ctx context.Context, limit int) ([]Transcript, error)
- func (c *Client) UpdatePersona(ctx context.Context, id string, payload any) (json.RawMessage, error)
- func (c *Client) UpdateRole(ctx context.Context, id string, payload any) (json.RawMessage, error)
- func (c *Client) UpdateSequence(ctx context.Context, id string, payload any) (json.RawMessage, error)
- func (c *Client) VocabularyEntries(ctx context.Context, language string) ([]DictionaryEntry, error)
- func (c *Client) VoiceAgentSessionSummary(ctx context.Context, id int64) (*VoiceAgentSummary, error)
- func (c *Client) VoiceAgentSessionTranscript(ctx context.Context, id int64) (*VoiceAgentTranscript, error)
- func (c *Client) Words(ctx context.Context, language string) ([]Word, error)
- type ConfigSummary
- type DictionaryEntry
- type HTTPError
- type Lexicon
- type Options
- type Pack
- type PersonaResource
- type ProviderDefault
- type ProviderMatrixRow
- type Replacement
- type RoleResource
- type Ruleset
- type SequenceResource
- type Status
- type TTSSynthesizeRequest
- type TTSSynthesizeResponse
- type TranscribeOptions
- type TranscribeResponse
- type Transcript
- type Voice
- type VoiceAgentFrame
- type VoiceAgentMessage
- type VoiceAgentSession
- func (s *VoiceAgentSession) AdvanceStep(ctx context.Context, reason string) error
- func (s *VoiceAgentSession) Close() error
- func (s *VoiceAgentSession) ReadMessage(ctx context.Context) (VoiceAgentMessage, error)
- func (s *VoiceAgentSession) SendAudio(ctx context.Context, chunk []byte) error
- func (s *VoiceAgentSession) SendAudioEnd(ctx context.Context) error
- func (s *VoiceAgentSession) SendStart(ctx context.Context, frame VoiceAgentStartFrame) error
- func (s *VoiceAgentSession) SendStop(ctx context.Context) error
- func (s *VoiceAgentSession) SendText(ctx context.Context, text string) error
- func (s *VoiceAgentSession) SessionID() string
- type VoiceAgentSessionOptions
- type VoiceAgentStartFrame
- type VoiceAgentSummary
- type VoiceAgentTicket
- type VoiceAgentTranscript
- type Word
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AudioAsset ¶
type AudioAsset struct {
StorageKind string `json:"storageKind"`
Path string `json:"path,omitempty"`
MimeType string `json:"mimeType"`
SizeBytes int64 `json:"sizeBytes"`
DurationMs int64 `json:"durationMs"`
}
AudioAsset describes the audio retained with a Transcript. StorageKind is the server's storage backend ("local-file" today), MimeType the stored encoding (audio/wav when unknown), SizeBytes the stored size and DurationMs the audio length. The current server never serializes Path.
type CatalogReadiness ¶
CatalogReadiness aliases framework.Readiness, the per-profile readiness report returned by Client.CatalogReadiness and Client.ProviderReadiness.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a typed caller for one SpeechKit Server. Every request carries Accept: application/json, the configured User-Agent and, when a token was given, a bearer Authorization header; non-2xx responses surface as HTTPError. A Client is immutable after New and safe for concurrent use.
func FromEnv ¶
FromEnv builds a Client from the environment: SPEECHKIT_SERVER_URL as the base URL (default http://localhost:8080) and SPEECHKIT_TOKEN, or failing that SPEECHKIT_SERVER_TOKEN, as the bearer token. It fails as New does.
func New ¶
New builds a Client from opts, applying the defaults described on Options. It performs no network I/O and returns an error only when BaseURL cannot be parsed or lacks a scheme or host.
func (*Client) CatalogContracts ¶
CatalogContracts calls GET /v1/catalog/contracts and returns the mode contracts (input, output, allowed and forbidden capabilities per mode) that the server enforces.
func (*Client) CatalogProfiles ¶
func (c *Client) CatalogProfiles(ctx context.Context, mode string) ([]framework.ProviderProfile, error)
CatalogProfiles calls GET /v1/catalog/profiles and returns the server's provider profiles. An empty mode returns every profile; otherwise mode must be "dictation", "assist", "voiceagent" or "voice_agent" and only that mode's profiles are returned (unknown modes yield a 400 HTTPError).
func (*Client) CatalogProviders ¶
func (c *Client) CatalogProviders(ctx context.Context) ([]catalog.ProviderMatrixRow, []catalog.ProviderDefault, error)
CatalogProviders calls GET /v1/catalog/providers and returns the provider feature matrix (one row per provider with its profiles and per-feature support) alongside the flat list of provider default profiles.
func (*Client) CatalogReadiness ¶
func (c *Client) CatalogReadiness(ctx context.Context) ([]CatalogReadiness, error)
CatalogReadiness calls GET /v1/catalog/readiness and returns one entry per provider profile in the server's default catalog, stating whether that profile is enabled, has credentials and can serve requests right now.
func (*Client) Config ¶
Config calls GET /v1/config and returns the server's redacted configuration summary (version, public_url, modes, auth_mode, feature flags, request limits and ready_status) as a generic JSON object; the key set is defined by the server, not by this package.
func (*Client) CreatePersona ¶
CreatePersona posts payload, any JSON-marshalable persona definition, to /v1/personas and returns the stored persona as raw JSON. The server needs an admin identity (403 otherwise) and rejects invalid definitions with 400.
func (*Client) CreateRole ¶
CreateRole posts payload, any JSON-marshalable role definition, to /v1/roles and returns the stored role as raw JSON. The server needs an admin identity (403 otherwise) and rejects invalid definitions with 400.
func (*Client) CreateSequence ¶
CreateSequence posts payload, any JSON-marshalable sequence definition, to /v1/sequences and returns the stored sequence as raw JSON. The server needs an admin identity (403 otherwise) and rejects invalid definitions with 400.
func (*Client) CreateVoiceAgentSession ¶
func (c *Client) CreateVoiceAgentSession(ctx context.Context) (*VoiceAgentTicket, error)
CreateVoiceAgentSession mints a session + ticket. Pair the result with DialVoiceAgent to upgrade to the WebSocket.
func (*Client) CreateVoiceAgentSessionWithOptions ¶
func (c *Client) CreateVoiceAgentSessionWithOptions(ctx context.Context, options VoiceAgentSessionOptions) (*VoiceAgentTicket, error)
CreateVoiceAgentSessionWithOptions mints a native/BYO session or selects a hosted registered agent when the caller also presents its capability lease.
func (*Client) CustomizationPack ¶
CustomizationPack calls GET /v1/customization/pack and returns the caller's Words, Replacements, Lexicons and Rulesets bundled as one exportable Pack with SchemaVersion and CreatedAt set by the server. A non-empty language limits the bundle to that language.
func (*Client) DeletePersona ¶
DeletePersona calls DELETE /v1/personas/{id}. Unlike Client.DeleteVoiceAgentSession it does not treat 404 as success; deleting an unknown persona returns an HTTPError.
func (*Client) DeleteRole ¶
DeleteRole calls DELETE /v1/roles/{id}; deleting an unknown role returns an HTTPError with status 404.
func (*Client) DeleteSequence ¶
DeleteSequence calls DELETE /v1/sequences/{id}; deleting an unknown sequence returns an HTTPError with status 404.
func (*Client) DeleteVoiceAgentSession ¶
DeleteVoiceAgentSession force-closes a session. Idempotent: 404 is treated as success because the server already removed it.
func (*Client) DialVoiceAgent ¶
func (c *Client) DialVoiceAgent(ctx context.Context, ticket *VoiceAgentTicket) (*VoiceAgentSession, error)
DialVoiceAgent upgrades the ticket to a WebSocket. The caller still needs to send a start frame (see VoiceAgentSession.SendStart) before any other I/O.
func (*Client) DoJSON ¶
DoJSON sends an HTTP request with method to path (resolved against the base URL; it may carry a query string) and decodes a 2xx response body into out. A non-nil body is JSON-encoded and sent as application/json. out may be nil to discard the response or a *json.RawMessage to receive it verbatim; an empty body leaves out unchanged. Non-2xx statuses return HTTPError carrying the raw body, and a nil receiver returns an error.
func (*Client) ImportCustomizationPack ¶
ImportCustomizationPack posts pack to /v1/customization/pack. The server validates it, then for each language present in the pack replaces the caller's stored Words, Replacements, Lexicons and Rulesets with the pack's items; languages absent from the pack are left untouched. It requires an admin identity (403 otherwise) and rejects invalid packs with 400.
func (*Client) Lexicons ¶
Lexicons calls GET /v1/lexicons and returns the caller's enabled Lexicons (named groups of Word IDs), limited to language when it is non-empty.
func (*Client) Persona ¶
Persona calls GET /v1/personas/{id} and returns one persona as raw JSON. The id is whitespace-trimmed and URL-escaped; an unknown persona surfaces as an HTTPError with status 404.
func (*Client) Personas ¶
Personas calls GET /v1/personas and returns the raw JSON envelope ({"personas": [...]}) so hosts can decode the "personas" array into their own persona type or into []PersonaResource.
func (*Client) PersonasList ¶
PersonasList calls GET /v1/personas and returns the raw JSON envelope; it is equivalent to Client.Personas.
func (*Client) ProviderReadiness ¶
ProviderReadiness calls GET /v1/catalog/profiles/{id}/readiness for one provider profile ID (whitespace-trimmed and URL-escaped). An unknown profile surfaces as an HTTPError with status 404.
func (*Client) RawJSON ¶
func (c *Client) RawJSON(ctx context.Context, method, path string, body any) (json.RawMessage, error)
RawJSON performs a request exactly like Client.DoJSON but returns the undecoded 2xx response body, so hosts can call endpoints this package has no typed method for. A response without a body yields a nil message.
func (*Client) ReplaceLexicons ¶
func (c *Client) ReplaceLexicons(ctx context.Context, language string, lexicons []Lexicon) ([]Lexicon, error)
ReplaceLexicons posts to /v1/lexicons, replacing the caller's stored Lexicons for language in one transaction, and returns the list as persisted. The server requires an admin identity (403 otherwise).
func (*Client) ReplaceReplacements ¶
func (c *Client) ReplaceReplacements(ctx context.Context, language string, replacements []Replacement) ([]Replacement, error)
ReplaceReplacements posts to /v1/replacements, replacing the caller's stored Replacements for language in one transaction, and returns the list as persisted. The server requires an admin identity (403 otherwise).
func (*Client) ReplaceRulesets ¶
func (c *Client) ReplaceRulesets(ctx context.Context, language string, rulesets []Ruleset) ([]Ruleset, error)
ReplaceRulesets posts to /v1/rulesets, replacing the caller's stored Rulesets for language in one transaction, and returns the list as persisted. The server requires an admin identity (403 otherwise).
func (*Client) ReplaceVocabularyEntries ¶
func (c *Client) ReplaceVocabularyEntries(ctx context.Context, language string, entries []DictionaryEntry) ([]DictionaryEntry, error)
ReplaceVocabularyEntries posts to /v1/vocabulary/dictionary, replacing the caller's stored dictionary for language with entries in one transaction, and returns the entries as persisted. Entries without Spoken or Canonical are dropped and an entry with an empty Language inherits language. The server requires an admin identity (403 otherwise).
func (*Client) ReplaceWords ¶
ReplaceWords posts to /v1/words, replacing the caller's stored Words for language in one transaction, and returns the list as persisted. The server requires an admin identity (403 otherwise).
func (*Client) Replacements ¶
Replacements calls GET /v1/replacements and returns the caller's enabled Replacements (post-recognition rewrite rules), limited to language when it is non-empty.
func (*Client) Role ¶
Role calls GET /v1/roles/{id} and returns one role as raw JSON; an unknown id surfaces as an HTTPError with status 404.
func (*Client) Roles ¶
Roles calls GET /v1/roles and returns the raw JSON envelope ({"roles": [...]}); see Client.Personas for the decoding pattern.
func (*Client) Rulesets ¶
Rulesets calls GET /v1/rulesets and returns the caller's enabled Rulesets (named groups of Replacement IDs), limited to language when it is non-empty.
func (*Client) Sequence ¶
Sequence calls GET /v1/sequences/{id} and returns one sequence as raw JSON; an unknown id surfaces as an HTTPError with status 404.
func (*Client) Sequences ¶
Sequences calls GET /v1/sequences and returns the raw JSON envelope ({"sequences": [...]}); see Client.Personas for the decoding pattern.
func (*Client) Status ¶
Status calls GET /readyz and decodes the readiness report. The server answers 503 while any blocking component is not "ok", so a not-ready server surfaces as an HTTPError (its Body still holds the JSON report) and a nil error means the server is ready to serve its enabled modes.
func (*Client) TTSSynthesize ¶
func (c *Client) TTSSynthesize(ctx context.Context, input TTSSynthesizeRequest) (*TTSSynthesizeResponse, error)
TTSSynthesize posts input to /v1/tts/synthesize and returns the synthesized audio. The server rejects an empty Text with 400 and answers 503 when no configured TTS provider can serve the request.
func (*Client) TTSVoices ¶
TTSVoices calls GET /v1/tts/voices and returns the voices the server's enabled TTS providers are configured to use. It is a configuration snapshot, not live provider voice discovery, and is empty when no TTS provider is enabled.
func (*Client) TranscribeFile ¶
func (c *Client) TranscribeFile(ctx context.Context, path string, opts TranscribeOptions) (*TranscribeResponse, error)
TranscribeFile uploads the audio file at path as a multipart/form-data POST to /v1/dictation/transcribe and returns the transcript. The file is read fully into memory first and is subject to the server's upload limit (25 MB by default). Empty opts fields are omitted from the form, and speaker fields are sent only when opts.Speaker asks for diarization.
func (*Client) Transcript ¶
Transcript calls GET /v1/transcripts/{id} and returns one persisted transcript. An unknown id surfaces as an HTTPError with status 404 and a transcript owned by another caller as 403.
func (*Client) Transcripts ¶
Transcripts calls GET /v1/transcripts and returns the caller's persisted dictation transcripts. limit > 0 is sent as ?limit= and must be at most 200 (the server rejects larger values with 400); limit <= 0 omits the parameter and yields the server default of 50.
func (*Client) UpdatePersona ¶
func (c *Client) UpdatePersona(ctx context.Context, id string, payload any) (json.RawMessage, error)
UpdatePersona sends payload as a PATCH to /v1/personas/{id} and returns the stored persona as raw JSON. The server treats payload as the complete definition (an upsert keyed by the path id, not a field-wise merge) and ignores any id inside payload.
func (*Client) UpdateRole ¶
UpdateRole sends payload as a PATCH to /v1/roles/{id} and returns the stored role as raw JSON. As with Client.UpdatePersona, payload is the complete definition and the path id wins over any id inside it.
func (*Client) UpdateSequence ¶
func (c *Client) UpdateSequence(ctx context.Context, id string, payload any) (json.RawMessage, error)
UpdateSequence sends payload as a PATCH to /v1/sequences/{id} and returns the stored sequence as raw JSON. As with Client.UpdatePersona, payload is the complete definition and the path id wins over any id inside it.
func (*Client) VocabularyEntries ¶
VocabularyEntries calls GET /v1/vocabulary/dictionary and returns the enabled user-dictionary entries visible to the caller. A non-empty language (whitespace-trimmed) restricts the result to that language plus language-neutral entries; an empty language returns every language.
func (*Client) VoiceAgentSessionSummary ¶
func (c *Client) VoiceAgentSessionSummary(ctx context.Context, id int64) (*VoiceAgentSummary, error)
VoiceAgentSessionSummary calls GET /v1/voiceagent/sessions/{id}/summary and returns the stored structured summary of a finished Voice Agent session. id is the numeric store record id, not the live session's string VoiceAgentTicket.SessionID; unknown ids yield a 404 HTTPError.
func (*Client) VoiceAgentSessionTranscript ¶
func (c *Client) VoiceAgentSessionTranscript(ctx context.Context, id int64) (*VoiceAgentTranscript, error)
VoiceAgentSessionTranscript calls GET /v1/voiceagent/sessions/{id}/transcript and returns the stored transcript and turns of a finished Voice Agent session. id is the numeric store record id, not the live session's string VoiceAgentTicket.SessionID; unknown ids yield a 404 HTTPError.
type ConfigSummary ¶
ConfigSummary names the generic JSON object returned by GET /v1/config (the map Client.Config returns) for hosts that want a typed alias for it.
type DictionaryEntry ¶
type DictionaryEntry struct {
ID int64 `json:"id,omitempty"`
Spoken string `json:"spoken"`
Canonical string `json:"canonical"`
Language string `json:"language"`
Source string `json:"source,omitempty"`
Enabled bool `json:"enabled"`
UsageCount int `json:"usageCount,omitempty"`
CreatedAt time.Time `json:"createdAt,omitempty"`
UpdatedAt time.Time `json:"updatedAt,omitempty"`
}
DictionaryEntry is one user-dictionary correction: Spoken is the text the recognizer tends to produce and Canonical the text to emit instead, scoped to Language (BCP-47). Source records where the entry came from and defaults to "settings" on write; UsageCount counts how often it matched. ID, CreatedAt and UpdatedAt are server-assigned and ignored on write.
type HTTPError ¶
HTTPError is the error every request method returns when the server answers with a status outside 2xx. Body is the raw response body, normally the server's JSON error envelope, so callers can branch on StatusCode with errors.As instead of parsing message text.
type Lexicon ¶
type Lexicon = speechcustomize.Lexicon
Lexicon aliases speechcustomize.Lexicon, a named group of Word IDs.
type Options ¶
type Options struct {
BaseURL string
Token string
HTTPClient *http.Client
UserAgent string
Timeout time.Duration
}
Options configures New. Every field is optional: an empty BaseURL means http://localhost:8080, an empty Token sends no Authorization header, a nil HTTPClient is replaced by one whose timeout is Timeout (30s when zero), and an empty UserAgent uses the package default. Timeout is ignored when HTTPClient is set.
type Pack ¶
type Pack = speechcustomize.Pack
Pack aliases speechcustomize.Pack, the exportable bundle of Words, Replacements, Lexicons and Rulesets exchanged by Client.CustomizationPack and Client.ImportCustomizationPack.
type PersonaResource ¶
PersonaResource is the untyped JSON object shape of one persona as served by the persona endpoints; decode Client.Persona output into it when a host has no persona type of its own.
type ProviderDefault ¶
type ProviderDefault = catalog.ProviderDefault
ProviderDefault aliases catalog.ProviderDefault, one default profile of a provider as listed by Client.CatalogProviders.
type ProviderMatrixRow ¶
type ProviderMatrixRow = catalog.ProviderMatrixRow
ProviderMatrixRow aliases catalog.ProviderMatrixRow, one provider's profiles and per-feature support as listed by Client.CatalogProviders.
type Replacement ¶
type Replacement = speechcustomize.Replacement
Replacement aliases speechcustomize.Replacement, one post-recognition rewrite rule (substitution, synonym, snippet, command or template).
type RoleResource ¶
RoleResource is the untyped JSON object shape of one role; see Client.Role.
type Ruleset ¶
type Ruleset = speechcustomize.Ruleset
Ruleset aliases speechcustomize.Ruleset, a named group of Replacement IDs.
type SequenceResource ¶
SequenceResource is the untyped JSON object shape of one sequence; see Client.Sequence.
type Status ¶
type Status struct {
Status string `json:"status"`
Components map[string]any `json:"components"`
UptimeSeconds int64 `json:"uptime_seconds"`
Version string `json:"version"`
}
Status is the GET /readyz body. Status is the overall readiness across blocking components ("ok", "starting", "degraded" or "unavailable"), Components maps each component name (for example "mode.dictation") to its status entry, UptimeSeconds counts seconds since the server started and Version is the server build.
type TTSSynthesizeRequest ¶
type TTSSynthesizeRequest struct {
Text string `json:"text"`
Locale string `json:"locale,omitempty"`
Voice string `json:"voice,omitempty"`
Speed float64 `json:"speed,omitempty"`
Format string `json:"format,omitempty"`
}
TTSSynthesizeRequest is the POST /v1/tts/synthesize body. Text is required. Locale (BCP-47), Voice (a provider voice id), Speed (rate multiplier where 1 is normal; 0 leaves the provider default and providers clamp to their own range) and Format ("mp3", "wav", "opus" or "pcm"; empty means the provider default) are optional.
type TTSSynthesizeResponse ¶
type TTSSynthesizeResponse struct {
AudioBase64 string `json:"audio_base64"`
Format string `json:"format"`
SampleRate int `json:"sample_rate,omitempty"`
DurationMs int64 `json:"duration_ms,omitempty"`
Provider string `json:"provider,omitempty"`
Voice string `json:"voice,omitempty"`
}
TTSSynthesizeResponse is the POST /v1/tts/synthesize body. AudioBase64 is the audio in Format, standard base64 (decode with base64.StdEncoding); SampleRate is in Hz and DurationMs the audio length, each 0 when the provider does not report it; Provider and Voice name what actually synthesized the text.
type TranscribeOptions ¶
type TranscribeOptions struct {
// Dictionary hints are forwarded separately so server vocabulary opt-outs work.
VocabularyHints speechcustomize.RecognitionHints
Keyterms []string
Options provideropts.Values
ProviderOptionsByProvider map[string]provideropts.Values
ProviderProfileID string
Language string
Model string
Prompt string
Speaker speaker.Options
}
TranscribeOptions holds the optional form fields of a Client.TranscribeFile upload. Language is a BCP-47 hint ("de", "en" or "auto"), Model an optional provider model override, Prompt a provider-specific recognition hint and Speaker the diarization or identification add-ons to request; the zero value transcribes only.
func (TranscribeOptions) WithVocabulary ¶
func (o TranscribeOptions) WithVocabulary(words []speechcustomize.Word) TranscribeOptions
WithVocabulary supplies dictionary-derived hints to the server using the same public customization rendering as embedded batch and streaming STT.
type TranscribeResponse ¶
type TranscribeResponse struct {
Text string `json:"text"`
Language string `json:"language,omitempty"`
DurationMs int64 `json:"duration_ms"`
LatencyMs int64 `json:"latency_ms"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
Confidence float64 `json:"confidence,omitempty"`
Speakers *speaker.DiarizationResult `json:"speakers,omitempty"`
CustomizationActions []framework.CustomizationAction `json:"customization_actions,omitempty"`
}
TranscribeResponse is the POST /v1/dictation/transcribe body. DurationMs is the decoded audio length and LatencyMs the server-side STT time. Confidence is the provider's overall score in [0,1], 0 when not reported; Speakers is set only when diarization ran; CustomizationActions lists the Replacement actions the server applied to Text.
type Transcript ¶
type Transcript struct {
ID int64 `json:"id"`
Text string `json:"text"`
Language string `json:"language"`
Provider string `json:"provider"`
Model string `json:"model"`
DurationMs int64 `json:"durationMs"`
LatencyMs int64 `json:"latencyMs"`
Audio *AudioAsset `json:"audio,omitempty"`
CreatedAt time.Time `json:"createdAt"`
OwnerUserID string `json:"ownerUserId,omitempty"`
OwnerOrgID string `json:"ownerOrgId,omitempty"`
OwnerSource string `json:"ownerSource,omitempty"`
Speakers *speaker.DiarizationResult `json:"speakers,omitempty"`
}
Transcript is one persisted dictation result as returned by Client.Transcripts and Client.Transcript. DurationMs is the audio length and LatencyMs the STT processing time; Audio is present only when audio was retained; the Owner fields carry the identity the server attributed the record to; Speakers is set when diarization ran.
type Voice ¶
type Voice struct {
Provider string `json:"provider"`
ID string `json:"id"`
Locale string `json:"locale"`
Default bool `json:"default"`
Discovery string `json:"discovery,omitempty"`
}
Voice is one entry of GET /v1/tts/voices: the voice ID (or model) a configured TTS Provider will use, its Locale ("auto" when the provider chooses per request), whether it is the server's Default and Discovery, always "configured" because the list is a configuration snapshot rather than live provider discovery.
type VoiceAgentFrame ¶
type VoiceAgentFrame struct {
Type string `json:"type"`
EventType string `json:"event_type,omitempty"`
EventTypes []string `json:"event_types,omitempty"`
State string `json:"state,omitempty"`
Text string `json:"text,omitempty"`
Done bool `json:"done,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Message string `json:"message,omitempty"`
Reason string `json:"reason,omitempty"`
SequenceID string `json:"sequence_id,omitempty"`
StepID string `json:"step_id,omitempty"`
StepIndex int `json:"step_index,omitempty"`
Status string `json:"status,omitempty"`
// Class is the served failure class of an error frame: limit, outage,
// right, consent or expired; empty for a code without one.
Class string `json:"class,omitempty"`
// ProviderMetadata carries provider-native detail, such as the
// `turn_timing` phase durations on a turn_end event.
ProviderMetadata map[string]any `json:"provider_metadata,omitempty"`
}
VoiceAgentFrame is the parsed shape of any inbound text frame. Binary frames carry audio and are returned via VoiceAgentMessage.Audio instead.
type VoiceAgentMessage ¶
type VoiceAgentMessage struct {
Audio []byte
Frame *VoiceAgentFrame
}
VoiceAgentMessage is a single inbound event. Exactly one of Audio or Frame is set per call to ReadMessage; audio chunks are raw PCM S16LE at 24 kHz mono (the SpeechKit Voice Agent output rate).
type VoiceAgentSession ¶
type VoiceAgentSession struct {
// contains filtered or unexported fields
}
VoiceAgentSession is a duplex WebSocket session. Use SendStart first, then SendText / SendAudio / SendAudioEnd to drive the conversation, and ReadMessage in a loop to consume server frames until SessionEnd arrives.
The zero value is unusable — always go through DialVoiceAgent.
func (*VoiceAgentSession) AdvanceStep ¶
func (s *VoiceAgentSession) AdvanceStep(ctx context.Context, reason string) error
AdvanceStep advances the active sequence step. Reason is optional and surfaces in the resulting sequence_step frame.
func (*VoiceAgentSession) Close ¶
func (s *VoiceAgentSession) Close() error
Close releases the WebSocket. Safe to call multiple times.
func (*VoiceAgentSession) ReadMessage ¶
func (s *VoiceAgentSession) ReadMessage(ctx context.Context) (VoiceAgentMessage, error)
ReadMessage blocks until the next inbound WebSocket message arrives. Binary frames are returned as Audio; text frames are decoded into Frame. Returns io.EOF or a websocket close error when the peer goes away.
func (*VoiceAgentSession) SendAudio ¶
func (s *VoiceAgentSession) SendAudio(ctx context.Context, chunk []byte) error
SendAudio forwards a PCM chunk (16 kHz, signed 16-bit little-endian, mono).
func (*VoiceAgentSession) SendAudioEnd ¶
func (s *VoiceAgentSession) SendAudioEnd(ctx context.Context) error
SendAudioEnd marks the end of the current microphone turn. Only needed when automatic activity detection is disabled.
func (*VoiceAgentSession) SendStart ¶
func (s *VoiceAgentSession) SendStart(ctx context.Context, frame VoiceAgentStartFrame) error
SendStart sends the mandatory first control frame. MediaTransport defaults to "websocket" when empty.
func (*VoiceAgentSession) SendStop ¶
func (s *VoiceAgentSession) SendStop(ctx context.Context) error
SendStop asks the server to gracefully end the session.
func (*VoiceAgentSession) SendText ¶
func (s *VoiceAgentSession) SendText(ctx context.Context, text string) error
SendText injects a text turn (the agent will reply via audio + transcript).
func (*VoiceAgentSession) SessionID ¶
func (s *VoiceAgentSession) SessionID() string
SessionID returns the manager-assigned session identifier.
type VoiceAgentSessionOptions ¶
type VoiceAgentSessionOptions struct {
AISessionID string `json:"ai_session_id,omitempty"`
Provider string `json:"provider,omitempty"`
TargetAgentID string `json:"target_agent_id,omitempty"`
}
VoiceAgentSessionOptions is the optional POST /v1/voiceagent/sessions body for Client.CreateVoiceAgentSessionWithOptions. AISessionID binds the voice session to a durable agent conversation and is echoed back by the server. Provider and TargetAgentID declare the intended backend: when the edge bound the request to a registered agent, the server rejects the create with 403 unless Provider is "kombify-agent" and TargetAgentID matches that binding. The realtime backend itself is still chosen by the start frame (VoiceAgentStartFrame.Provider) or the server default. The zero value mints a plain native session.
type VoiceAgentStartFrame ¶
type VoiceAgentStartFrame struct {
PersonaID string `json:"persona_id,omitempty"`
RoleID string `json:"role_id,omitempty"`
SequenceID string `json:"sequence_id,omitempty"`
Provider string `json:"provider,omitempty"`
// MediaProvider selects native conversation media (for example
// "deepgram") for a session the edge bound to a registered agent; the
// agent keeps reasoning and tools. Empty keeps the session's default.
MediaProvider string `json:"media_provider,omitempty"`
MediaTransport string `json:"media_transport,omitempty"` // "websocket" (default) or "livekit"
Voice string `json:"voice,omitempty"`
Locale string `json:"locale,omitempty"`
Model string `json:"model,omitempty"`
Thinking string `json:"thinking,omitempty"`
SystemPromptOverride string `json:"system_prompt_override,omitempty"`
}
VoiceAgentStartFrame opens a session and binds it to a persona/role/sequence. PersonaID is required if the deployment has any personas; the server's resolver falls back to the configured default persona when empty.
type VoiceAgentSummary ¶
type VoiceAgentSummary struct {
ID int64 `json:"id"`
Summary map[string]any `json:"summary"`
Language string `json:"language"`
CreatedAt time.Time `json:"created_at"`
}
VoiceAgentSummary is the GET /v1/voiceagent/sessions/{id}/summary body. Summary is the server's structured summary object with "title", "summary", "ideas", "decisions", "openQuestions", "nextSteps" and "rawText" keys.
type VoiceAgentTicket ¶
type VoiceAgentTicket struct {
SessionID string `json:"session_id"`
WSURL string `json:"ws_url"`
WSSubprotocol string `json:"ws_subprotocol,omitempty"`
Ticket string `json:"ticket"`
ExpiresAt time.Time `json:"expires_at"`
}
VoiceAgentTicket is the minted session envelope returned by POST /v1/voiceagent/sessions. DialVoiceAgent prefers WSSubprotocol so the one-time ticket does not have to ride in the URL.
type VoiceAgentTranscript ¶
type VoiceAgentTranscript struct {
ID int64 `json:"id"`
Transcript string `json:"transcript"`
Turns []map[string]any `json:"turns,omitempty"`
Language string `json:"language"`
CreatedAt time.Time `json:"created_at"`
}
VoiceAgentTranscript is the GET /v1/voiceagent/sessions/{id}/transcript body: the flattened Transcript of a persisted session plus its Turns, each a JSON object with "role", "text" and "createdAt" keys.
type Word ¶
type Word = speechcustomize.Word
Word aliases speechcustomize.Word, one vocabulary bias term.