sim

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package sim is talkie's test bench: real speech clips, the real Silero VAD, a scripted wake word and a simulated room whose speaker echoes into the microphone. Tests drive an engine with it in lock-step, like an audio device but faster than real time. Ported from wonky-talkie's tests/harness.py and EchoRoom.

Index

Constants

View Source
const Rate = 16000

Rate is the microphone and simulated speaker rate.

Variables

View Source
var Voices = []string{"af_heart", "am_michael", "bf_emma"}

Voices are the Kokoro voices with wake word clips.

Functions

func AgentVoice

func AgentVoice(tb testing.TB, seconds float64) []float32

AgentVoice is continuous speech used as the agent's synthesized voice.

func Clip

func Clip(tb testing.TB, name string, from, to float64) []float32

Clip returns from..to seconds of a testdata clip; to 0 means its end.

func Command

func Command(tb testing.TB) []float32

Command is about 2.7 s of speech, isolated by silence in the source clip: "So if we turn that off, does it work with".

func DecodeWAV

func DecodeWAV(data []byte) ([]float32, error)

DecodeWAV decodes mono 16-bit PCM at 16 kHz to float32.

func SaysConfusable

func SaysConfusable(tb testing.TB, voice string) []float32

SaysConfusable is voice saying "hey commuter", which PhonMatchNet can score as high as "hey computer".

func SaysWakeWord

func SaysWakeWord(tb testing.TB, voice string) []float32

SaysWakeWord is voice saying "hey computer", synthesized by Kokoro.

func ShortReply

func ShortReply(tb testing.TB) []float32

ShortReply is about 1.6 s of speech: "Turn on the office lights."

func VAD

func VAD(tb testing.TB) func([]float32) (float32, error)

VAD returns a Silero VAD stream for one test, skipping the test unless TALKIE_TEST_ORT names an ONNX Runtime library.

func WakePhrase

func WakePhrase(tb testing.TB) []float32

WakePhrase is "hey mycroft", 0.95 s.

Types

type Noise

type Noise struct {
	// contains filtered or unexported fields
}

Noise makes room noise at about -65 dBFS, reproducibly.

func NewNoise

func NewNoise() *Noise

NewNoise returns a noise source with a fixed seed.

func (*Noise) Silence

func (n *Noise) Silence(seconds float64) []float32

Silence returns seconds of room noise.

type Room

type Room struct {
	// contains filtered or unexported fields
}

Room is a simulated speaker -> room -> mic path: the agent's audio comes back delayed (80 ms), reverberant (300 ms RT60), slightly distorted and 6 dB down, plus room noise. Without echo it is a headset: the mic hears only the user.

func NewRoom

func NewRoom(echo bool) *Room

NewRoom returns a room, with the speaker's echo reaching the mic or not.

func NewRoomDelay

func NewRoomDelay(echo bool, delayMS int, gainDB float64) *Room

NewRoomDelay is NewRoom with a speaker-to-mic delay of delayMS and an echo gainDB relative to what the speaker played. NewRoom is 80 ms and -6 dB; a loud speaker near a sensitive microphone can be +8 dB and slower.

func (*Room) Mix

func (r *Room) Mix(user, ref []float32) []float32

Mix returns what the mic hears while the user says user and the speaker plays ref.

type Wake

type Wake struct {
	// contains filtered or unexported fields
}

Wake fires at fixed stream positions.

func NewWake

func NewWake(at ...float64) *Wake

NewWake fires once at each of the given stream times, in seconds.

func (*Wake) Write

func (w *Wake) Write(_ context.Context, samples []float32) ([]int64, error)

Write implements the engine's Wake.

Jump to

Keyboard shortcuts

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