Docs / Troubleshooting

AMD Troubleshooting Guide

A dialer-agnostic guide to the failure modes that show up integrating AMDY answering machine detection, regardless of whether you run Asterisk, FreeSWITCH, Issabel, or a custom SIP stack. Everything here expands on the platform-specific notes in the Asterisk install guide without contradicting it — if you are on Asterisk, read the AMDSTATUS section below alongside that guide.

Silence detection issues

Legacy timing-based AMD (Asterisk’s stock app_amd is the canonical example) decides HUMAN vs. MACHINE purely from silence and utterance durations after answer: how long the line is silent, how long the first continuous utterance runs, and how many separate utterances arrive before a timeout. AMDY’s model classifies from the acoustic signature of the answer audio itself rather than pause timing, but the pipeline still depends on getting real answer-audio silence boundaries, so the same symptoms apply if your telephony leg mishandles silence:

  • Comfort noise / silence suppression (RFC 3389 CN) enabled on the trunk injects synthetic background noise during actual silence, which can mask the initial silence period the detector uses to bound the analysis window. Disable silence suppression on the SIP trunk or PBX leg feeding the detection stream.
  • Answer supervision that fires early (a carrier or gateway signals 200 OK / answer before a human or machine has actually picked up) starts the detection clock on dead air, which can look identical to a machine’s pre-greeting silence. This is a carrier-side false-answer problem, not a detector bug — check your carrier’s early-media / progress handling.
  • Clipped or truncated first buffer — if your integration does not start streaming audio to AMDY until a moment after true answer, the leading silence and the first word or two of a greeting can be lost, which removes information the classifier needs.

Codec mismatches (G.711 / G.729 / Opus)

AMDY’s WebSocket protocol expects raw 8 kHz, 16-bit, mono, linear PCM (see the WebSocket streaming guide). It does not decode compressed RTP payloads itself — your dialplan or media layer is responsible for transcoding to linear PCM before the audio reaches the EAGI script, the FreeSWITCH module, or whatever bridges audio to the detection socket.

  • G.711 (µ-law/A-law) is the easy case: it is already 8 kHz and near-lossless, so the PCM conversion is a straight decode with no resampling. If your trunk negotiates G.711, codec mismatch is rarely the cause of bad detections.
  • G.729 is a low-bitrate compressed codec. Decoding it introduces quantization artifacts, and some open-source G.729 implementations subtly alter formant shape in ways that can shift a marginal detection. If detection accuracy looks worse on a specific trunk, check whether that trunk is negotiating G.729 and compare against a G.711-only test call.
  • Opus / wideband codecs run at 16 kHz or 48 kHz internally. If your media stack decodes Opus and forwards it to AMDY without resampling down to 8 kHz, the WebSocket server will either reject the stream or (if your client naively byte-packs wideband samples as if they were 8 kHz) produce audio that plays back at the wrong pitch and speed — which looks to the classifier like garbled or corrupted speech. Always resample to 8 kHz mono before sending.
  • Mid-call codec renegotiation (a re-INVITE that switches codecs partway through the answer window) can introduce a discontinuity in the decoded PCM stream — a short glitch or dropout right at the point of renegotiation — which is worth checking for if detections are inconsistent on calls through carriers known to renegotiate.

Audio format problems (sample rate, mono/stereo)

The detection WebSocket is strict about input format: 8 kHz, 16-bit signed linear PCM, mono. Common integration mistakes:

  • Wrong sample rate. Sending 16 kHz or 44.1 kHz audio without resampling makes speech sound sped up (or, if the receiving side assumes a higher rate than actual, slowed down and pitch-shifted) to the model, which degrades detection quality. If you resample client-side with the Web Audio API or a DSP library, verify the output sample count matches 8000 samples/second exactly — off-by-a-fraction resampling ratios accumulate drift over a multi-second buffer.
  • Stereo instead of mono. A stereo stream interleaves two channels of samples; if it is sent as if it were mono PCM, every other sample is read as the wrong channel, which produces audio that sounds like static or a buzzing artifact rather than speech. Mix down to a single channel before streaming.
  • Byte order / endianness. 16-bit PCM samples must be little-endian on the wire for the AMDY protocol. Audio generated on a platform that defaults to big-endian samples (some embedded telephony stacks) needs an explicit byte-swap.
  • Chunk size. The streaming protocol expects audio in small, regular chunks (see the streaming guide for exact chunking cadence). Sending audio in irregular bursts, or buffering an entire call before sending, defeats the low-latency design of the pipeline and can cause the server to time out waiting for the next chunk.

Latency in the detection pipeline

A typical detection returns within 1-3 seconds of answer, once enough audio has streamed to reach a confident classification. If you are seeing detections take noticeably longer, check each link in the chain rather than assuming the model is slow:

  • Network round-trip to the WebSocket endpoint. The detection socket is a hosted service (wss://api.amdy.io:2443, with ws://api.amdy.io:2700 as fallback); a dialer on a network path with high latency or packet loss to that endpoint adds real delay before the first classification result is even attempted. Test round-trip time from the dialer host, not from your workstation.
  • Chunking interval. If your integration buffers audio into large chunks before sending (rather than streaming in the small intervals the protocol expects), the server cannot start analyzing until the first chunk arrives, which pushes out the effective latency regardless of how fast the model itself runs.
  • CPU contention on the dialer host — if the process doing audio capture/streaming (the EAGI script, the FreeSWITCH module, your custom bridge) is starved for CPU on a heavily loaded dialer, audio chunks queue up before being sent, which shows up as latency in the detection result even though the AMDY service itself responded promptly.
  • Waiting for a timeout instead of a result. If a call never produces a clear detection (e.g. total silence, or audio that never resolves to HUMAN or MACHINE with confidence), the client-side code should honor whatever timeout it is configured with and route on the default rather than blocking indefinitely. Confirm your integration has a timeout configured and that it is shorter than your acceptable answer-to-bridge delay.

Network failure handling

The detection service is reached over the network, so your integration needs an explicit policy for when that network call fails — a dropped WebSocket, a connection refused, a DNS failure, or a timeout with no response at all.

  • Fail safe, not silent. On a connection error, route the call as if a human answered rather than dropping it — hanging up on a live person because of a network blip is worse than occasionally bridging an agent to a machine. This is the default behavior of the reference EAGI script (see the AMDSTATUS section below) and should be the default in any custom integration too.
  • Log the actual failure, not just the fallback. A fallback to HUMAN on error will look, from the dialplan’s perspective, identical to a real human detection unless you log the underlying network error separately. Without that log line, a sustained outage (e.g. a firewall change blocking outbound ports 2443 and 2700) can silently degrade every call’s detection to the fallback value for hours before anyone notices.
  • Verify outbound connectivity as a standing check, not just at install time. Firewall rule changes, egress proxy changes, or a carrier-side NAT change can all break connectivity to the detection endpoint after a working install. A periodic connectivity check (even a simple scripted WebSocket connect-and-close) catches this before it shows up as a spike in false HUMAN routing.
  • Distinguish connection errors from timeout errors. A connection refused/DNS failure is usually an infrastructure problem (firewall, DNS, service outage). A timeout with an open connection but no response is more often an audio-format or chunking problem upstream in this guide. Treating them the same in your logs makes root-causing harder.

Incorrect AMDSTATUS routing (Asterisk / dialplan-specific)

AMDSTATUS, AMDCAUSE, and AMDSTATS are Asterisk dialplan channel variables specific to the EAGI integration path (see the Asterisk install guide for how they are set). Other platforms return the equivalent result over their own mechanism — a Lua variable for FreeSWITCH’s mod_audio_fork driver, or a JSON field for a custom WebSocket client — but the class of bug below applies wherever a dialplan reads a result variable set by an external script.

Dialplan reads the variable before it is set

EAGI() (or the equivalent app call) must complete before the next dialplan line reads ${AMDSTATUS}. If a prior line in the same extension caches the channel variable, or if the extension is structured so a GotoIf runs on a priority that executes before the EAGI application returns, the read will see a stale or empty value from a previous call on a reused channel. Confirm the GotoIf line is the priority immediately after the EAGI call, as shown in the install guide’s dialplan example.

Variable scope across Gosub / Macro

If the EAGI call happens inside a Gosub() or Macro(), channel variables set inside it are local to that context unless explicitly propagated. Use GLOBAL() or return the value explicitly if the routing logic that reads AMDSTATUS lives outside the subroutine that set it.

Case sensitivity and exact string match

Asterisk dialplan string comparisons are case-sensitive. ${AMDSTATUS} returns exactly HUMAN or AMD (uppercase). A condition written as $["${AMDSTATUS}" = "Human"] will never match and will silently fall through to the else branch on every call — this is one of the more common copy-paste bugs when adapting a dialplan snippet.

AMDSTATUS always HUMAN

As noted above, the script defaults to HUMAN on connection errors by design. Before assuming a dialplan bug, check AMDCAUSE — if it consistently reads CONNECTION_ERROR rather than HUMAN or MACHINE, the routing logic is correct and the real problem is network connectivity (see the section above), not the dialplan.

Support

Still stuck? Email [email protected] with:

  • Which platform you’re integrating with (Asterisk, FreeSWITCH, Issabel, custom)
  • A sample of the raw audio you are streaming, if possible, or the codec/sample-rate settings on the trunk
  • The AMDCAUSE value (or your platform’s equivalent result code) for a call that failed to classify correctly
  • Any relevant logs around the failure (dialplan trace, EAGI script stderr, WebSocket connection errors)
AMD troubleshooting guide — silence, codecs, audio format, latency, AMDSTATUS routing | AMDY.IO