mock

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package mock provides mock STT, LLM, and TTS services for testing and stress testing without calling real APIs. All mocks are configurable (response text, audio length, optional latency).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LLM

type LLM struct {
	// Response is the text streamed via onToken (one rune per call).
	Response string
	// Latency is the optional delay before starting (for latency simulation).
	Latency time.Duration
}

LLM is a mock LLM service that streams a configurable response.

func NewLLM

func NewLLM() *LLM

NewLLM returns a mock LLM with default response "hi there".

func NewLLMWithResponse

func NewLLMWithResponse(response string) *LLM

NewLLMWithResponse returns a mock LLM that streams the given response.

func (*LLM) Chat

func (m *LLM) Chat(ctx context.Context, messages []map[string]any, onToken func(*frames.LLMTextFrame)) error

Chat streams the configured response via onToken, one rune at a time.

type STT

type STT struct {
	// Transcript is the text returned for every Transcribe call.
	Transcript string
	// Transcripts is used for round-robin when set (non-empty); overrides Transcript.
	Transcripts []string
	// Latency is the optional delay before returning (for latency simulation).
	Latency time.Duration
	// contains filtered or unexported fields
}

STT is a mock STT service that returns configurable transcription(s).

func NewSTT

func NewSTT() *STT

NewSTT returns a mock STT with default transcript "hello".

func NewSTTWithTranscript

func NewSTTWithTranscript(transcript string) *STT

NewSTTWithTranscript returns a mock STT that always returns the given transcript.

func (*STT) Transcribe

func (m *STT) Transcribe(ctx context.Context, audio []byte, sampleRate, numChannels int) ([]*frames.TranscriptionFrame, error)

Transcribe returns one or more TranscriptionFrame with the configured text.

type TTS

type TTS struct {
	// AudioBytes is the number of bytes of audio to return per Speak call (default 2400 = 50ms at 24kHz mono 16-bit).
	AudioBytes int
	// SampleRate is the sample rate of the returned audio (default 24000).
	SampleRate int
	// Latency is the optional delay before returning (for latency simulation).
	Latency time.Duration
}

TTS is a mock TTS service that returns configurable audio (e.g. silence).

func NewTTS

func NewTTS() *TTS

NewTTS returns a mock TTS that returns a short silence buffer.

func (*TTS) Speak

func (m *TTS) Speak(ctx context.Context, text string, sampleRate int) ([]*frames.TTSAudioRawFrame, error)

Speak returns one or more TTSAudioRawFrame with the configured payload.

Jump to

Keyboard shortcuts

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