speech

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 26 Imported by: 1 module, 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 speech implements graph-native speech synthesis and playback elements. Synthesis and playback are intentionally separate: generating audio is reversible computation, while handing a paced frame to a sink is an irreversible external effect.

Index

Constants

View Source
const (
	TTSProviderRegistryService   = "speech.tts.providers"
	PlaybackSinkRegistryService  = "speech.playback.sinks"
	IrreversibilityLedgerService = "action.irreversibility.ledger"
	PlaybackSchedulerService     = "speech.playback.scheduler"
)

Variables

This section is empty.

Functions

func AudioType

func AudioType() element.Type

func CancelType

func CancelType() element.Type

func Descriptors

func Descriptors() []element.Descriptor

func FactoryRegistrations

func FactoryRegistrations() ([]graphruntime.FactoryRegistration, error)

func PlaybackDescriptor

func PlaybackDescriptor() element.Descriptor

func PlaybackOutcomeType

func PlaybackOutcomeType() element.Type

func PlaybackReceiptType

func PlaybackReceiptType() element.Type

func PlaybackReleaseType

func PlaybackReleaseType() element.Type

PlaybackReleaseType carries the exact output state that a policy consumer must apply before exposing the corresponding turn completion.

func ProviderResolutionType

func ProviderResolutionType() element.Type

func RegisterDescriptors

func RegisterDescriptors(catalog *resolve.Catalog) error

func RegisterFactories

func RegisterFactories(registry *graphruntime.Registry) error

func SinkResolutionType

func SinkResolutionType() element.Type

func SynthesisOutcomeType

func SynthesisOutcomeType() element.Type

func TTSDescriptor

func TTSDescriptor() element.Descriptor

func TextSegmentType

func TextSegmentType() element.Type

Public type helpers let graph boundaries construct exact envelopes without exporting mutable package-level Type values.

func TransitionType

func TransitionType() element.Type

Types

type AudioFrame

type AudioFrame struct {
	Kind            AudioFrameKind   `json:"kind"`
	UtteranceID     string           `json:"utterance_id"`
	Utterance       action.Utterance `json:"utterance,omitempty"`
	SpeechAuthority string           `json:"speech_authority,omitempty"`
	Chunk           v1.SpeechChunk   `json:"chunk,omitempty"`
	Terminal        SynthesisOutcome `json:"terminal,omitempty"`
}

AudioFrame is the explicit framing carried by the Segmented audio port. Begin owns utterance metadata, Chunk owns immutable PCM, and End carries the synthesis terminal result. Playback never guesses completion from silence.

type AudioFrameKind

type AudioFrameKind string
const (
	AudioBegin AudioFrameKind = "begin"
	AudioChunk AudioFrameKind = "chunk"
	AudioEnd   AudioFrameKind = "end"
)

type Cancel

type Cancel struct {
	UtteranceID string `json:"utterance_id,omitempty"`
	RunID       string `json:"run_id,omitempty"`
	Reason      string `json:"reason,omitempty"`
}

Cancel is an addressed interruption. An empty ID uses the envelope's cancellation scope; it never means "cancel every utterance" implicitly. Cancel stops speech. Addressed to an utterance it stops that one; addressed to a run it stops every utterance of the run - the one playing, the ones queued, and any that arrive later - because a run that was cancelled has nothing left worth hearing. A count the policy stopped kept playing for six seconds when only the utterances already seen were named.

type OutcomeKind

type OutcomeKind string
const (
	OutcomeSucceeded OutcomeKind = "succeeded"
	OutcomeCancelled OutcomeKind = "cancelled"
	OutcomeRefused   OutcomeKind = "refused"
	OutcomeFailed    OutcomeKind = "failed"
	OutcomeIgnored   OutcomeKind = "ignored"
)

type PlaybackConfig

type PlaybackConfig struct {
	Sink            string `json:"sink"`
	FrameDurationMS int    `json:"frame_duration_ms,omitempty"`
	MaxChunkBytes   int    `json:"max_chunk_bytes,omitempty"`
	CancelMemory    int    `json:"cancel_memory,omitempty"`
}

type PlaybackOutcome

type PlaybackOutcome struct {
	UtteranceID     string      `json:"utterance_id,omitempty"`
	Kind            OutcomeKind `json:"kind"`
	CrossedBoundary bool        `json:"crossed_boundary"`
	PlayedNS        uint64      `json:"played_ns,omitempty"`
	Code            string      `json:"code,omitempty"`
	Message         string      `json:"message,omitempty"`
}

type PlaybackReceipt

type PlaybackReceipt struct {
	Kind      PlaybackReceiptKind `json:"kind"`
	Sequence  uint64              `json:"sequence"`
	Utterance action.Utterance    `json:"utterance"`
	Frame     action.Frame        `json:"frame,omitempty"`
	Outcome   action.Outcome      `json:"outcome,omitempty"`
}

PlaybackReceipt is a post-success receipt for one concrete sink effect. Every kind has its own graph port, so an adapter can attest a presentation seam without aliasing a generic status stream. Sequence and the receipt envelopes' causal parents establish the exact effect order.

type PlaybackReceiptKind

type PlaybackReceiptKind string
const (
	PlaybackReserved      PlaybackReceiptKind = "reserved"
	PlaybackBegun         PlaybackReceiptKind = "begun"
	PlaybackTextCommitted PlaybackReceiptKind = "text_committed"
	PlaybackAudioEmitted  PlaybackReceiptKind = "audio_emitted"
	PlaybackEnded         PlaybackReceiptKind = "ended"
	PlaybackReleased      PlaybackReceiptKind = "released"
)

type PlaybackRelease

type PlaybackRelease struct {
	Receipt           PlaybackReceipt             `json:"receipt"`
	AgentOutput       coreinteraction.AgentOutput `json:"agent_output"`
	AgentOutputItemID string                      `json:"agent_output_item_id"`
}

type PlaybackSink

type PlaybackSink interface {
	action.SpeechSink
	Descriptor() v1.Descriptor
}

PlaybackSink extends the proven action-plane sink contract with a live descriptor. A legacy sink can be adapted explicitly; the graph never treats a deployment assertion as proof of what resource was actually mounted.

type PlaybackSinkFactory

type PlaybackSinkFactory func() (PlaybackSink, error)

type PlaybackSinkRegistry

type PlaybackSinkRegistry struct {
	// contains filtered or unexported fields
}

func NewPlaybackSinkRegistry

func NewPlaybackSinkRegistry() *PlaybackSinkRegistry

func (*PlaybackSinkRegistry) Register

func (registry *PlaybackSinkRegistry) Register(
	reference string, descriptor v1.Descriptor, factory PlaybackSinkFactory,
) error

type PlaybackTimingSource

type PlaybackTimingSource interface {
	PlaybackTiming() spoken.TrackerConfig
}

PlaybackTimingSource is the optional deployment seam through which an exact playback sink supplies its session-local word aligner. The graph element owns the Tracker because it alone sees both all synthesised audio and the exact frames that crossed the playback boundary.

type ProviderResolution

type ProviderResolution struct {
	Reference  string          `json:"reference"`
	Descriptor v1.Descriptor   `json:"descriptor"`
	Selected   map[string]bool `json:"selected,omitempty"`
}

type SinkResolution

type SinkResolution struct {
	Reference  string          `json:"reference"`
	Descriptor v1.Descriptor   `json:"descriptor"`
	Selected   map[string]bool `json:"selected,omitempty"`
}

type Stage

type Stage string
const (
	StageSynthesis Stage = "synthesis"
	StagePlayback  Stage = "playback"
)

type State

type State string
const (
	StateGenerating State = "generating"
	StateGenerated  State = "generated"
	StateQueued     State = "queued"
	StateEmitting   State = "emitting"
	StatePlayed     State = "played"
	StateCancelled  State = "cancelled"
	StateFailed     State = "failed"
	StateRefused    State = "refused"
)

type SynthesisOutcome

type SynthesisOutcome struct {
	UtteranceID string      `json:"utterance_id,omitempty"`
	Kind        OutcomeKind `json:"kind"`
	Chunks      uint64      `json:"chunks,omitempty"`
	AudioBytes  uint64      `json:"audio_bytes,omitempty"`
	Code        string      `json:"code,omitempty"`
	Message     string      `json:"message,omitempty"`
}

type TTSConfig

type TTSConfig struct {
	Provider      string `json:"provider"`
	MaxTextBytes  int    `json:"max_text_bytes,omitempty"`
	MaxChunkBytes int    `json:"max_chunk_bytes,omitempty"`
	MaxAudioBytes int    `json:"max_audio_bytes,omitempty"`
	CancelMemory  int    `json:"cancel_memory,omitempty"`
}

type TTSProviderFactory

type TTSProviderFactory func() (v1.SpeechProvider, error)

type TTSProviderRegistry

type TTSProviderRegistry struct {
	// contains filtered or unexported fields
}

TTSProviderRegistry is deployment-owned provider resolution. Graph source contains only the symbolic reference selected in the separate values artifact; credentials and concrete clients never enter topology or Graph IR.

func NewTTSProviderRegistry

func NewTTSProviderRegistry() *TTSProviderRegistry

func (*TTSProviderRegistry) Register

func (registry *TTSProviderRegistry) Register(
	reference string, descriptor v1.Descriptor, factory TTSProviderFactory,
) error

type TextSegment

type TextSegment struct {
	ID               string           `json:"id"`
	Text             string           `json:"text"`
	Producer         string           `json:"producer,omitempty"`
	Phase            trajectory.Phase `json:"phase,omitempty"`
	SpeechAuthority  string           `json:"speech_authority,omitempty"`
	SourceRevision   uint64           `json:"source_revision,omitempty"`
	AssistantItemIDs []string         `json:"assistant_item_ids,omitempty"`
	Continuer        bool             `json:"continuer,omitempty"`
	SpokeOver        bool             `json:"spoke_over,omitempty"`
}

TextSegment is one complete, safe-to-speak unit. Segmentation policy lives upstream and can therefore be replaced without changing either TTS or playback. Phase is provenance only; no phase is privileged or forbidden.

type Transition

type Transition struct {
	UtteranceID     string       `json:"utterance_id"`
	Stage           Stage        `json:"stage"`
	State           State        `json:"state"`
	CrossedBoundary bool         `json:"crossed_boundary"`
	PlayedNS        uint64       `json:"played_ns,omitempty"`
	Reason          string       `json:"reason,omitempty"`
	LedgerState     action.State `json:"ledger_state,omitempty"`
}

Transition makes the lifecycle visible to graph policy and inspection. CrossedBoundary is false for reversible cancellation and true once at least one audio frame may have reached the world.

Jump to

Keyboard shortcuts

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