dtmf

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: BSD-2-Clause Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dtmf aggregates the DTMF keypresses a caller makes into a string a language model can read. Aggregator collects the keys and flushes them on a terminator key or an idle timeout.

Generating the tones for a key is a separate concern and lives in audio/dtmf, which is what an output transport sounds when it has to carry a keypress as audio.

Index

Constants

View Source
const DefaultPrefix = "DTMF: "

DefaultPrefix is what the emitted transcription starts with, so the model can tell a keypad entry from something the user said.

View Source
const DefaultTimeout = 2 * time.Second

DefaultTimeout is how long the aggregator waits after the last key before it flushes the digits collected without a terminator.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregator

type Aggregator struct {
	*processor.Base
	// contains filtered or unexported fields
}

Aggregator collects the DTMF keys received from the transport into a string and emits it downstream as a TranscriptionFrame — so an LLM can react to the entered sequence — when the terminator key is pressed or the idle timeout elapses. It forwards the InputDTMFFrames it sees unchanged.

func NewAggregator

func NewAggregator(cfg AggregatorConfig) *Aggregator

NewAggregator builds a DTMF Aggregator.

func (*Aggregator) Cleanup

func (a *Aggregator) Cleanup(ctx context.Context) error

Cleanup stops the idle timer and tears down the processor.

func (*Aggregator) ProcessFrame

func (a *Aggregator) ProcessFrame(ctx context.Context, f frames.Frame, dir processor.Direction) error

ProcessFrame aggregates DTMF keypresses and forwards every frame.

type AggregatorConfig

type AggregatorConfig struct {
	// Terminator is the key that flushes the collected digits; empty uses '#'.
	Terminator frames.KeypadEntry
	// Timeout flushes the collected digits after this idle period even without a
	// terminator. Zero uses DefaultTimeout; a negative value turns the timeout
	// off, so only the terminator flushes.
	Timeout time.Duration
	// Prefix is prepended to the emitted transcription. Nil uses DefaultPrefix;
	// point it at "" for none.
	Prefix *string
}

AggregatorConfig configures a DTMF Aggregator. The zero value is the defaults: '#' ends an entry, two idle seconds flush one without it, and the transcription starts "DTMF: ".

Jump to

Keyboard shortcuts

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