Documentation
¶
Overview ¶
Package stttest contains deterministic STT test doubles. Nothing in this package performs network I/O or starts work before FakeSTT.Stream is called.
Index ¶
- Constants
- Variables
- func EmptyAudioFrame() agents.AudioFrame
- type FakeRecognizeStream
- type FakeSTT
- func (f *FakeSTT) Close(ctx context.Context) error
- func (f *FakeSTT) DroppedObservations() uint64
- func (f *FakeSTT) FakeUserSpeechesDone() <-chan struct{}
- func (f *FakeSTT) Recognize(ctx context.Context, _ []agents.AudioFrame, _ stt.RecognizeOptions) (stt.SpeechEvent, error)
- func (f *FakeSTT) RecognizeCalls() stream.Reader[RecognizeSentinel]
- func (f *FakeSTT) Stream(ctx context.Context, _ stt.StreamOptions) (stt.SpeechStream, error)
- func (f *FakeSTT) Streams() stream.Reader[*FakeRecognizeStream]
- func (f *FakeSTT) UpdateOptions(options FakeSTTUpdateOptions) error
- type FakeSTTOptions
- type FakeSTTUpdateOptions
- type FakeUserSpeech
- type RecognizeSentinel
Constants ¶
const ( DefaultObservationCapacity = 128 DefaultStreamCapacity = 64 )
Variables ¶
var ErrFakeSTTClosed = errors.New("fake STT is closed")
Functions ¶
func EmptyAudioFrame ¶
func EmptyAudioFrame() agents.AudioFrame
EmptyAudioFrame is a zero-sample PCM frame suitable for batch fake calls.
Types ¶
type FakeRecognizeStream ¶
type FakeRecognizeStream struct {
*stt.BaseStream
// contains filtered or unexported fields
}
FakeRecognizeStream is returned by FakeSTT.Stream. SendFakeTranscript can be used to inject additional output while the scripted stream is active.
func (*FakeRecognizeStream) Attempt ¶
func (s *FakeRecognizeStream) Attempt() int64
func (*FakeRecognizeStream) SendFakeTranscript ¶
type FakeSTT ¶
FakeSTT is a concurrency-safe scripted STT for fallback, recognition, and full agent-session tests. Observation streams are bounded and never block a model call; DroppedObservations reports saturation rather than hiding it.
func NewFakeSTT ¶
func NewFakeSTT(options FakeSTTOptions) (*FakeSTT, error)
func (*FakeSTT) DroppedObservations ¶
func (*FakeSTT) FakeUserSpeechesDone ¶
func (f *FakeSTT) FakeUserSpeechesDone() <-chan struct{}
func (*FakeSTT) Recognize ¶
func (f *FakeSTT) Recognize(ctx context.Context, _ []agents.AudioFrame, _ stt.RecognizeOptions) (stt.SpeechEvent, error)
func (*FakeSTT) RecognizeCalls ¶
func (f *FakeSTT) RecognizeCalls() stream.Reader[RecognizeSentinel]
func (*FakeSTT) Stream ¶
func (f *FakeSTT) Stream(ctx context.Context, _ stt.StreamOptions) (stt.SpeechStream, error)
func (*FakeSTT) UpdateOptions ¶
func (f *FakeSTT) UpdateOptions(options FakeSTTUpdateOptions) error
type FakeSTTOptions ¶
type FakeSTTUpdateOptions ¶
type FakeSTTUpdateOptions struct {
FakeException agents.Override[error]
FakeTranscript agents.Override[string]
FakeTimeout agents.Override[time.Duration]
}
FakeSTTUpdateOptions uses Override so tests can distinguish “leave this knob unchanged”, “clear it”, and “set it (including to a zero value)”.
type FakeUserSpeech ¶
type FakeUserSpeech struct {
StartTime time.Duration
EndTime time.Duration
Transcript string
STTDelay time.Duration
Final *bool
}
FakeUserSpeech describes a transcript scheduled relative to the first audio frame pushed into a stream. Interim text is emitted at EndTime+STTDelay/2 and final text at EndTime+STTDelay. StartTime is used to validate non-overlap.
func SpeedUpFakeUserSpeech ¶
func SpeedUpFakeUserSpeech(speech FakeUserSpeech, factor float64) FakeUserSpeech
SpeedUpFakeUserSpeech scales all scheduled durations. A factor above one makes a fixture faster. Invalid factors return the original value.
type RecognizeSentinel ¶
type RecognizeSentinel struct{}
RecognizeSentinel is emitted once for every batch Recognize call.