companion

package
v0.68.21 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 1 package

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 companion provides small composers for hands-free SpeechKit hosts.

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingAssist = errors.New("speechkit companion: assist service is required")
View Source
var ErrMissingContext = errors.New("speechkit companion: context is required")
View Source
var ErrMissingRuntime = errors.New("speechkit companion: runtime is required")

Functions

This section is empty.

Types

type HandsFree

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

func NewHandsFree

func NewHandsFree(opts Options) (*HandsFree, error)

func (*HandsFree) Assist

func (h *HandsFree) Assist() speechkit.AssistService

func (*HandsFree) Events

func (h *HandsFree) Events() <-chan speechkit.Event

func (*HandsFree) HandleWake

func (h *HandsFree) HandleWake(ctx context.Context, ev wakeword.DetectionEvent) error

HandleWake publishes a wake event, forwards it to the optional downstream sink, and starts the configured hands-free target. Assist and Voice Agent can run without a visible UI; Dictation is UI-assisted and dispatches into the host command bus so the host can choose the text target and commit surface.

func (*HandsFree) ProcessAssist

ProcessAssist runs a one-shot Assist request through the configured service and, when TTS is present, synthesizes the spoken response.

func (*HandsFree) Runtime

func (h *HandsFree) Runtime() *speechkit.Runtime

func (*HandsFree) Start

func (h *HandsFree) Start(ctx context.Context) error

func (*HandsFree) Stop

func (h *HandsFree) Stop(ctx context.Context) error

func (*HandsFree) TTS

func (h *HandsFree) TTS() *tts.Service

func (*HandsFree) VoiceAgent

func (h *HandsFree) VoiceAgent() speechkit.VoiceAgentService

func (*HandsFree) WakeSink

func (h *HandsFree) WakeSink() wakeword.Sink

type HandsFreeTarget added in v0.40.7

type HandsFreeTarget string

HandsFreeTarget identifies which strict SpeechKit mode a hands-free activation should start. Hands-free is a capability layer, not a fourth SpeechKit mode.

const (
	// TargetAssist runs a one-shot Assist request and may synthesize spoken
	// output. This is the Siri/Alexa-style Voice-Companion path.
	TargetAssist HandsFreeTarget = "assist"
	// TargetVoiceAgent starts a realtime Voice Agent session for continuous
	// dialogue such as companion or game-moderator flows.
	TargetVoiceAgent HandsFreeTarget = "voice_agent"
	// TargetDictationUIAssisted starts Dictation through the host command bus.
	// It intentionally does not synthesize audio: text output still belongs to
	// a visible target or explicit commit surface owned by the host UI.
	TargetDictationUIAssisted HandsFreeTarget = "dictation_ui_assisted"
)

type Options

type Options struct {
	Runtime     *speechkit.Runtime
	TargetMode  HandsFreeTarget
	WakeSink    wakeword.Sink
	WakeRequest WakeRequestFunc
	Assist      speechkit.AssistService
	VoiceAgent  speechkit.VoiceAgentService
	TTS         *tts.Service
	// OnResult, when set, receives the AssistResult (including any synthesized
	// Audio) produced by a wake-triggered Assist turn, so the host can play it
	// back. It runs synchronously inside HandleWake after ProcessAssist
	// succeeds; hosts that want async playback should spawn their own goroutine.
	OnResult func(context.Context, speechkit.AssistResult)
	// OnStage, when set, receives turn-lifecycle stages so hosts can drive a
	// status UI (e.g. the kombify box ring) from the canonical flow instead of
	// scraping logs or events. Called synchronously — keep handlers fast.
	OnStage func(Stage)
}

type Stage added in v0.50.0

type Stage string

Stage identifies a coarse phase of a hands-free turn. Stages are a UI vocabulary (status ring, tray icon, LED), deliberately smaller than the runtime event stream: one linear wake → listening → thinking → speaking → idle sequence per Assist turn, with error as the terminal failure stage.

const (
	StageWake      Stage = "wake"
	StageListening Stage = "listening"
	StageThinking  Stage = "thinking"
	StageSpeaking  Stage = "speaking"
	StageIdle      Stage = "idle"
	StageError     Stage = "error"
)

type WakeRequestFunc

WakeRequestFunc converts a wake detection into an Assist request. Hosts use it to attach their transcript/capture result to the framework composer.

Jump to

Keyboard shortcuts

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