Documentation
¶
Index ¶
- type AlignedTranscript
- type AvailabilityChangedEvent
- type Base
- func (b *Base) Capabilities() Capabilities
- func (b *Base) EmitError(event ErrorEvent)
- func (b *Base) EmitMetrics(metric metrics.STT)
- func (b *Base) Label() string
- func (b *Base) Model() string
- func (b *Base) OnError(fn func(ErrorEvent)) func()
- func (b *Base) OnMetrics(fn func(metrics.STT)) func()
- func (b *Base) Provider() string
- func (b *Base) SetModel(model string)
- func (b *Base) UpdateCapabilities(update func(*Capabilities))
- type BaseStream
- func (s *BaseStream) Close() error
- func (s *BaseStream) Context() context.Context
- func (s *BaseStream) Emit(ctx context.Context, event SpeechEvent) error
- func (s *BaseStream) EndInput() error
- func (s *BaseStream) Finish(err error)
- func (s *BaseStream) Flush(ctx context.Context) error
- func (s *BaseStream) Inputs() stream.Reader[StreamInput]
- func (s *BaseStream) Push(ctx context.Context, frame agents.AudioFrame) error
- func (s *BaseStream) Recv(ctx context.Context) (SpeechEvent, error)
- type Capabilities
- type ErrorEvent
- type FallbackAdapter
- func (a *FallbackAdapter) AttemptTimeout() time.Duration
- func (a *FallbackAdapter) Availability() []bool
- func (a *FallbackAdapter) Capabilities() Capabilities
- func (a *FallbackAdapter) Close(ctx context.Context) error
- func (a *FallbackAdapter) Instances() []STT
- func (a *FallbackAdapter) Label() string
- func (a *FallbackAdapter) MaxRetriesPerSTT() int
- func (a *FallbackAdapter) Model() string
- func (a *FallbackAdapter) OnAvailabilityChanged(fn func(AvailabilityChangedEvent)) func()
- func (a *FallbackAdapter) OnError(fn func(ErrorEvent)) func()
- func (a *FallbackAdapter) OnMetrics(fn func(metrics.STT)) func()
- func (a *FallbackAdapter) Provider() string
- func (a *FallbackAdapter) Recognize(parent context.Context, frames []agents.AudioFrame, options RecognizeOptions) (SpeechEvent, error)
- func (a *FallbackAdapter) RetryInterval() time.Duration
- func (a *FallbackAdapter) STTs() []STT
- func (a *FallbackAdapter) Status() []FallbackStatus
- func (a *FallbackAdapter) Stream(parent context.Context, options StreamOptions) (SpeechStream, error)
- type FallbackOptions
- type FallbackStatus
- type RecognitionUsage
- type RecognizeOptions
- type STT
- type SessionKeytermUpdater
- type SpeechData
- type SpeechEvent
- type SpeechEventType
- type SpeechStream
- type StreamAdapter
- func (a *StreamAdapter) Capabilities() Capabilities
- func (a *StreamAdapter) Close(ctx context.Context) error
- func (a *StreamAdapter) Label() string
- func (a *StreamAdapter) Model() string
- func (a *StreamAdapter) OnError(fn func(ErrorEvent)) func()
- func (a *StreamAdapter) OnMetrics(fn func(metrics.STT)) func()
- func (a *StreamAdapter) Provider() string
- func (a *StreamAdapter) Recognize(ctx context.Context, frames []agents.AudioFrame, options RecognizeOptions) (SpeechEvent, error)
- func (a *StreamAdapter) Stream(parent context.Context, options StreamOptions) (SpeechStream, error)
- func (a *StreamAdapter) WrappedSTT() STT
- type StreamAdapterOptions
- type StreamAdapterWrapper
- type StreamInput
- type StreamOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlignedTranscript ¶
type AlignedTranscript string
const ( AlignedTranscriptNone AlignedTranscript = "" AlignedTranscriptWord AlignedTranscript = "word" AlignedTranscriptChunk AlignedTranscript = "chunk" )
type AvailabilityChangedEvent ¶
AvailabilityChangedEvent reports a provider entering or leaving the fallback rotation.
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
Base implements provider metadata and typed events for STT implementations.
func NewBase ¶
func NewBase(label, provider, model string, capabilities Capabilities) *Base
func (*Base) Capabilities ¶
func (b *Base) Capabilities() Capabilities
func (*Base) EmitError ¶
func (b *Base) EmitError(event ErrorEvent)
func (*Base) EmitMetrics ¶
func (*Base) OnError ¶
func (b *Base) OnError(fn func(ErrorEvent)) func()
func (*Base) UpdateCapabilities ¶
func (b *Base) UpdateCapabilities(update func(*Capabilities))
type BaseStream ¶
type BaseStream struct {
// contains filtered or unexported fields
}
BaseStream supplies bounded input/output, lifecycle, and cancellation. A provider owns the run goroutine and consumes Inputs until io.EOF.
func NewBaseStream ¶
func NewBaseStream(parent context.Context, capacity int) *BaseStream
func (*BaseStream) Close ¶
func (s *BaseStream) Close() error
func (*BaseStream) Context ¶
func (s *BaseStream) Context() context.Context
func (*BaseStream) Emit ¶
func (s *BaseStream) Emit(ctx context.Context, event SpeechEvent) error
func (*BaseStream) EndInput ¶
func (s *BaseStream) EndInput() error
func (*BaseStream) Finish ¶
func (s *BaseStream) Finish(err error)
func (*BaseStream) Inputs ¶
func (s *BaseStream) Inputs() stream.Reader[StreamInput]
func (*BaseStream) Push ¶
func (s *BaseStream) Push(ctx context.Context, frame agents.AudioFrame) error
func (*BaseStream) Recv ¶
func (s *BaseStream) Recv(ctx context.Context) (SpeechEvent, error)
type Capabilities ¶
type ErrorEvent ¶
type FallbackAdapter ¶
type FallbackAdapter struct {
// contains filtered or unexported fields
}
FallbackAdapter provides ordered STT failover, health recovery, automatic VAD wrapping for batch-only providers, and dynamic provider attribution.
func NewFallbackAdapter ¶
func NewFallbackAdapter(options FallbackOptions) (*FallbackAdapter, error)
func (*FallbackAdapter) AttemptTimeout ¶
func (a *FallbackAdapter) AttemptTimeout() time.Duration
func (*FallbackAdapter) Availability ¶
func (a *FallbackAdapter) Availability() []bool
func (*FallbackAdapter) Capabilities ¶
func (a *FallbackAdapter) Capabilities() Capabilities
func (*FallbackAdapter) Instances ¶
func (a *FallbackAdapter) Instances() []STT
Instances is a Python/TypeScript-friendly alias for STTs.
func (*FallbackAdapter) Label ¶
func (a *FallbackAdapter) Label() string
func (*FallbackAdapter) MaxRetriesPerSTT ¶
func (a *FallbackAdapter) MaxRetriesPerSTT() int
func (*FallbackAdapter) Model ¶
func (a *FallbackAdapter) Model() string
func (*FallbackAdapter) OnAvailabilityChanged ¶
func (a *FallbackAdapter) OnAvailabilityChanged(fn func(AvailabilityChangedEvent)) func()
func (*FallbackAdapter) OnError ¶
func (a *FallbackAdapter) OnError(fn func(ErrorEvent)) func()
func (*FallbackAdapter) OnMetrics ¶
func (a *FallbackAdapter) OnMetrics(fn func(metrics.STT)) func()
func (*FallbackAdapter) Provider ¶
func (a *FallbackAdapter) Provider() string
func (*FallbackAdapter) Recognize ¶
func (a *FallbackAdapter) Recognize(parent context.Context, frames []agents.AudioFrame, options RecognizeOptions) (SpeechEvent, error)
func (*FallbackAdapter) RetryInterval ¶
func (a *FallbackAdapter) RetryInterval() time.Duration
func (*FallbackAdapter) STTs ¶
func (a *FallbackAdapter) STTs() []STT
func (*FallbackAdapter) Status ¶
func (a *FallbackAdapter) Status() []FallbackStatus
func (*FallbackAdapter) Stream ¶
func (a *FallbackAdapter) Stream(parent context.Context, options StreamOptions) (SpeechStream, error)
type FallbackOptions ¶
type FallbackOptions struct {
STTs []STT
// STTInstances is the agents-js-compatible spelling. Set only one of
// STTs or STTInstances.
STTInstances []STT
VAD vad.VAD
AttemptTimeout time.Duration
MaxRetriesPerSTT int
// MaxRetryPerSTT is the agents-js-compatible spelling. Non-zero values
// override MaxRetriesPerSTT.
MaxRetryPerSTT int
RetryInterval time.Duration
StreamCapacity int
// KeepProvidersOpen leaves the original STT instances caller-owned. By
// default Close shuts them down after all adapter work has stopped.
KeepProvidersOpen bool
}
FallbackOptions configures ordered STT failover. A zero timeout, retry interval, or stream capacity selects the agents-js 1.7 defaults. A zero MaxRetriesPerSTT selects the default of one; use a negative value to disable child retries explicitly (mirroring APIConnectOptions).
type FallbackStatus ¶
FallbackStatus is an immutable status snapshot.
type RecognitionUsage ¶
type RecognizeOptions ¶
type RecognizeOptions struct {
ConnectOptions agents.APIConnectOptions
Language agents.LanguageCode
}
type STT ¶
type STT interface {
Label() string
Provider() string
Model() string
Capabilities() Capabilities
Recognize(context.Context, []agents.AudioFrame, RecognizeOptions) (SpeechEvent, error)
Stream(context.Context, StreamOptions) (SpeechStream, error)
Close(context.Context) error
OnMetrics(func(metrics.STT)) func()
OnError(func(ErrorEvent)) func()
}
type SessionKeytermUpdater ¶
SessionKeytermUpdater is implemented by recognizers that can update the framework-managed keyterm overlay without replacing caller-provided model options. AgentSession uses this optional interface only when Capabilities().Keyterms is true.
Implementations must copy keyterms before returning. An empty slice clears keyterms left by a previous session binding.
type SpeechData ¶
type SpeechData struct {
Language agents.LanguageCode
Text string
StartTime time.Duration
EndTime time.Duration
Confidence float64
Words []agents.TimedString
SpeakerID string
SourceLanguages []agents.LanguageCode
SourceTexts []string
TargetLanguages []agents.LanguageCode
TargetTexts []string
Metadata map[string]any
}
type SpeechEvent ¶
type SpeechEvent struct {
Type SpeechEventType
Alternatives []SpeechData
RequestID string
RecognitionUsage *RecognitionUsage
}
func MeasureRecognize ¶
func MeasureRecognize( ctx context.Context, base *Base, frames []agents.AudioFrame, request func(context.Context) (SpeechEvent, error), ) (SpeechEvent, error)
MeasureRecognize provides the common metrics behavior of the TS/Python base class while leaving the provider request implementation allocation-free.
type SpeechEventType ¶
type SpeechEventType uint8
const ( StartOfSpeech SpeechEventType = iota InterimTranscript FinalTranscript EndOfSpeech RecognitionUsageEvent PreflightTranscript )
type SpeechStream ¶
type StreamAdapter ¶
type StreamAdapter struct {
// contains filtered or unexported fields
}
StreamAdapter turns a batch STT into a streaming STT by recognizing each utterance delimited by a VAD. The wrapped STT and VAD remain caller-owned. Child metrics and errors are forwarded without generating duplicate adapter metrics.
func NewStreamAdapter ¶
func NewStreamAdapter(wrapped STT, detector vad.VAD, options ...StreamAdapterOptions) (*StreamAdapter, error)
NewStreamAdapter constructs a VAD-backed streaming adapter. At most one options value is accepted.
func (*StreamAdapter) Capabilities ¶
func (a *StreamAdapter) Capabilities() Capabilities
func (*StreamAdapter) Close ¶
func (a *StreamAdapter) Close(ctx context.Context) error
Close cancels active adapter streams, detaches forwarded listeners, and waits for their goroutines. It intentionally does not close the caller-owned wrapped STT or VAD.
func (*StreamAdapter) Label ¶
func (a *StreamAdapter) Label() string
func (*StreamAdapter) Model ¶
func (a *StreamAdapter) Model() string
func (*StreamAdapter) OnError ¶
func (a *StreamAdapter) OnError(fn func(ErrorEvent)) func()
func (*StreamAdapter) OnMetrics ¶
func (a *StreamAdapter) OnMetrics(fn func(metrics.STT)) func()
func (*StreamAdapter) Provider ¶
func (a *StreamAdapter) Provider() string
func (*StreamAdapter) Recognize ¶
func (a *StreamAdapter) Recognize(ctx context.Context, frames []agents.AudioFrame, options RecognizeOptions) (SpeechEvent, error)
func (*StreamAdapter) Stream ¶
func (a *StreamAdapter) Stream(parent context.Context, options StreamOptions) (SpeechStream, error)
func (*StreamAdapter) WrappedSTT ¶
func (a *StreamAdapter) WrappedSTT() STT
type StreamAdapterOptions ¶
type StreamAdapterOptions struct {
StreamCapacity int
}
StreamAdapterOptions controls the bounded queues used by StreamAdapter. Zero values select production defaults.
type StreamAdapterWrapper ¶
type StreamAdapterWrapper struct {
*BaseStream
// contains filtered or unexported fields
}
StreamAdapterWrapper is the concrete SpeechStream returned by StreamAdapter. Wait is useful when deterministic shutdown is required.
func (*StreamAdapterWrapper) Close ¶
func (s *StreamAdapterWrapper) Close() error
type StreamInput ¶
type StreamInput struct {
Frame *agents.AudioFrame
Flush bool
}
type StreamOptions ¶
type StreamOptions struct {
ConnectOptions agents.APIConnectOptions
Language agents.LanguageCode
}