stttest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

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

View Source
const (
	DefaultObservationCapacity = 128
	DefaultStreamCapacity      = 64
)

Variables

View Source
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

func (s *FakeRecognizeStream) SendFakeTranscript(ctx context.Context, transcript string, final bool) error

type FakeSTT

type FakeSTT struct {
	*stt.Base
	// contains filtered or unexported fields
}

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) Close

func (f *FakeSTT) Close(ctx context.Context) error

func (*FakeSTT) DroppedObservations

func (f *FakeSTT) DroppedObservations() uint64

func (*FakeSTT) FakeUserSpeechesDone

func (f *FakeSTT) FakeUserSpeechesDone() <-chan struct{}

func (*FakeSTT) Recognize

func (*FakeSTT) RecognizeCalls

func (f *FakeSTT) RecognizeCalls() stream.Reader[RecognizeSentinel]

func (*FakeSTT) Stream

func (*FakeSTT) Streams

func (f *FakeSTT) Streams() stream.Reader[*FakeRecognizeStream]

func (*FakeSTT) UpdateOptions

func (f *FakeSTT) UpdateOptions(options FakeSTTUpdateOptions) error

type FakeSTTOptions

type FakeSTTOptions struct {
	Label            string
	Provider         string
	Model            string
	FakeException    error
	FakeTranscript   *string
	FakeTimeout      time.Duration
	FakeUserSpeeches []FakeUserSpeech
	FakeRequireAudio bool
	Capabilities     *stt.Capabilities

	ObservationCapacity int
	StreamCapacity      int
}

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.

Jump to

Keyboard shortcuts

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