Documentation
¶
Overview ¶
Package cadence provides provider-agnostic voice AI engines: streaming speech-to-text, text-to-speech and LLM chat behind small uniform interfaces, plus the glue a real-time voice pipeline needs between them (sentence-aligned buffering for TTS, local energy VAD).
The engine implementations and their contracts live in the engines subpackage; G.711/PCM audio helpers live in audio. This root package carries the pieces that sit between engines: RunSentenceBuffer turns an LLM token stream into TTS-sized sentences, and EnergyVAD detects speech onset/offset for STT engines without server-side endpointing.
Cadence deliberately does not include a conversation loop — turn-taking, barge-in policy and dialogue state belong to the application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EnergyVAD ¶
type EnergyVAD struct {
// contains filtered or unexported fields
}
EnergyVAD is a stateful, RMS-based voice activity detector. It consumes 20 ms frames of mu-law 8 kHz audio (160 bytes each) and reports whether the user has just stopped speaking.
The detector is intentionally simple — speech-vs-silence by short-time RMS against a fixed threshold, with frame-count debouncing for both onset and offset. Replace with Silero (CGo onnxruntime) when noise robustness matters.
func NewEnergyVAD ¶
func NewEnergyVAD() *EnergyVAD
type SentenceBufferConfig ¶
type SentenceBufferConfig struct {
ClauseMinWords int // flush at "," ";" ":" "—" only after this many words
MaxWords int // hard cap regardless of punctuation
FlushTimeout time.Duration // flush after this much idle time since last delta
}
SentenceBufferConfig tunes the LLM-to-TTS framing pipeline. Defaults match the original Rust prototype: flush on hard sentence terminators, on clause boundaries once enough words have accumulated, on inactivity, or on a hard word cap. The numbers trade first-token latency against TTS prosody.
func DefaultSentenceBufferConfig ¶
func DefaultSentenceBufferConfig() SentenceBufferConfig
type SentenceBufferResult ¶
SentenceBufferResult is what RunSentenceBuffer hands back when the upstream LLM event channel closes.
func RunSentenceBuffer ¶
func RunSentenceBuffer( ctx context.Context, cfg SentenceBufferConfig, in <-chan engines.LLMEvent, out chan<- string, ) SentenceBufferResult
RunSentenceBuffer consumes a stream of LLMEvents (text deltas + tool calls) and emits sentence-aligned text chunks downstream so TTS can begin synthesising before the LLM has finished generating. Returns once `in` closes or `ctx` cancels.
`out` is closed before return so the consuming TTS goroutine unblocks.
Directories
¶
| Path | Synopsis |
|---|---|
|
bench
|
|
|
e2ebench
command
e2ebench — live pipeline latency decomposition for cadence.
|
e2ebench — live pipeline latency decomposition for cadence. |
|
sbbench
command
sbbench — sentence-buffer latency characterization for cadence.
|
sbbench — sentence-buffer latency characterization for cadence. |
|
vadbench
command
vadbench — endpointing characterization for cadence's EnergyVAD.
|
vadbench — endpointing characterization for cadence's EnergyVAD. |
|
Package engines defines the pluggable STT, LLM, and TTS interfaces that the cadence orchestrator composes into a voice pipeline.
|
Package engines defines the pluggable STT, LLM, and TTS interfaces that the cadence orchestrator composes into a voice pipeline. |