Documentation
¶
Overview ¶
Package wakeword exposes embeddable SpeechKit wake-word contracts.
Index ¶
- Constants
- func FrameDuration() time.Duration
- type AutoEndConfig
- type AutoEndPolicy
- type Config
- type DetectionEvent
- type Detector
- type DetectorConfig
- type Dispatcher
- type DispatcherOptions
- type EndReason
- type HotkeyEvent
- type HotkeySink
- type HotkeySinkFunc
- type PhraseCatalogEntry
- type Pipeline
- type Sink
- type SinkFunc
Constants ¶
const ( SampleRate = 16000 BytesPerSample = 2 Channels = 1 FrameSamples = 1280 FrameBytes = FrameSamples * BytesPerSample FrameDur = 80 * time.Millisecond SourceWakeword = "wakeword" )
Variables ¶
This section is empty.
Functions ¶
func FrameDuration ¶
FrameDuration returns the fixed PCM frame duration.
Types ¶
type AutoEndConfig ¶
AutoEndConfig controls when a wake-triggered session automatically ends.
func DefaultAutoEndConfig ¶
func DefaultAutoEndConfig() AutoEndConfig
DefaultAutoEndConfig returns SpeechKit's framework baseline.
type AutoEndPolicy ¶
type AutoEndPolicy struct {
// contains filtered or unexported fields
}
AutoEndPolicy watches activity/transcripts and fires an end signal once.
func NewAutoEndPolicy ¶
func NewAutoEndPolicy(cfg AutoEndConfig, logger *slog.Logger) *AutoEndPolicy
NewAutoEndPolicy constructs a policy from config.
func (*AutoEndPolicy) Close ¶
func (p *AutoEndPolicy) Close()
Close stops timers and closes EndSignal if it has not fired.
func (*AutoEndPolicy) Config ¶
func (p *AutoEndPolicy) Config() AutoEndConfig
Config returns a copy of the policy config.
func (*AutoEndPolicy) EndSignal ¶
func (p *AutoEndPolicy) EndSignal() <-chan EndReason
EndSignal fires when the policy decides the session should end.
func (*AutoEndPolicy) NotifyActivity ¶
func (p *AutoEndPolicy) NotifyActivity()
NotifyActivity resets the silence timer.
func (*AutoEndPolicy) NotifyTranscript ¶
func (p *AutoEndPolicy) NotifyTranscript(text string)
NotifyTranscript checks text against configured exit phrases.
type Config ¶
type Config struct {
Enabled bool
Phrase string
ModelDir string
KeywordsFile string
Keywords []string
DefaultMode string
Threshold float32
MinConsecutiveFrames int
Cooldown time.Duration
AutoEnd AutoEndConfig
}
Config controls wake-word pipeline behavior.
type DetectionEvent ¶
type DetectionEvent struct {
Phrase string
Keyword string
Mode string
Probability float32
At time.Time
}
DetectionEvent is emitted when a keyword fires.
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector owns the sherpa-onnx KeywordSpotter.
func NewDetector ¶
func NewDetector(cfg DetectorConfig) (*Detector, error)
NewDetector loads the sherpa-onnx KWS model.
type DetectorConfig ¶
type DetectorConfig struct {
Encoder string
Decoder string
Joiner string
Tokens string
KeywordsFile string
Keywords []string
NumThreads int
Threshold float32
Debug bool
}
DetectorConfig bundles file-system inputs for the sherpa-onnx KWS engine.
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher converts DetectionEvents into synthetic hotkey events.
func NewDispatcher ¶
func NewDispatcher(sink HotkeySink, opts DispatcherOptions) *Dispatcher
NewDispatcher constructs a Dispatcher with the given sink and options.
func (*Dispatcher) Close ¶
func (d *Dispatcher) Close(ctx context.Context) error
Close blocks further events and waits for in-flight dispatches.
func (*Dispatcher) Emit ¶
func (d *Dispatcher) Emit(ev DetectionEvent)
Emit implements Sink. It is non-blocking for the caller.
type DispatcherOptions ¶
type DispatcherOptions struct {
SyntheticRelease bool
ReleaseAfter time.Duration
Logger *slog.Logger
}
DispatcherOptions tweaks Dispatcher behavior.
type HotkeyEvent ¶
HotkeyEvent is the minimal event shape needed to bridge wake-word triggers into a host's mode activation path.
type HotkeySink ¶
type HotkeySink interface {
Submit(HotkeyEvent)
}
HotkeySink consumes synthetic key events.
type HotkeySinkFunc ¶
type HotkeySinkFunc func(HotkeyEvent)
HotkeySinkFunc adapts a plain function to HotkeySink.
type PhraseCatalogEntry ¶
PhraseCatalogEntry describes a curated wake phrase.
func DefaultCatalog ¶
func DefaultCatalog() []PhraseCatalogEntry
DefaultCatalog returns SpeechKit's curated wake-phrase list.
func LookupPhrase ¶
func LookupPhrase(id string) *PhraseCatalogEntry
LookupPhrase returns the catalog entry matching id.
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline streams PCM audio into a sherpa-onnx KeywordSpotter.
func NewPipeline ¶
NewPipeline wires a Detector and Sink together.
type Sink ¶
type Sink interface {
Emit(DetectionEvent)
}
Sink receives DetectionEvents from a wake-word pipeline.