Documentation
¶
Overview ¶
Package amd implements classic Answering Machine Detection (AMD) by analysing the first few seconds of audio on an outbound call. It measures initial silence, greeting duration and speech/silence patterns to classify the answerer as human, machine, no-speech or not-sure.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Analyzer ¶
type Analyzer struct {
// contains filtered or unexported fields
}
Analyzer performs answering machine detection on a 16 kHz PCM audio stream.
func (*Analyzer) Run ¶
Run blocks while reading 16 kHz 16-bit mono PCM from reader, analysing up to TotalAnalysisTime of audio. It returns a Detection when a determination is made or the context is cancelled.
func (*Analyzer) WaitForBeep ¶
WaitForBeep continues reading audio after a "machine" classification, looking for the voicemail beep tone (800–1200 Hz). It blocks until the beep is found, the timeout expires, or the context is cancelled.
type BeepResult ¶
type BeepResult struct {
Detected bool
BeepMs int // ms from start of beep waiting to detection (0 if not detected)
}
BeepResult holds the outcome of beep detection after a machine classification.
type Detection ¶
type Detection struct {
Result Result
InitialSilenceMs int
GreetingDurationMs int
TotalAnalysisMs int
}
Detection holds the AMD result and timing measurements.
type Params ¶
type Params struct {
InitialSilenceTimeout time.Duration // max silence before no_speech
GreetingDuration time.Duration // speech length threshold for machine
AfterGreetingSilence time.Duration // silence after speech to declare human
TotalAnalysisTime time.Duration // hard analysis deadline
MinimumWordLength time.Duration // min speech burst to count as a word
// Beep detection — after classifying "machine", continue listening for
// the voicemail beep tone so the caller knows when to start speaking.
// Set to 0 to disable beep detection (default).
BeepTimeout time.Duration // max time to wait for beep after machine detection
}
Params controls the AMD analysis thresholds.
func DefaultParams ¶
func DefaultParams() Params
DefaultParams returns AMD parameters with sensible defaults matching industry-standard answering machine detection (Asterisk, FreeSWITCH).
func MergeMillis ¶
func MergeMillis(defaults Params, initialSilenceMs, greetingMs, afterGreetingMs, totalMs, minWordMs, beepTimeoutMs int) Params
MergeMillis builds Params by starting from defaults, then overriding with any non-zero millisecond values from the per-call API request.