Skip to main content

Voicemail Detector for Python

Answering machine detection for outbound calls and voice AI. Send the callee's audio and get back human, machine or unknown, usually within 2.5 to 4.5 seconds of the answer. The call never waits for the verdict: your agent or voice AI talks from the first second, and you hang up on machines when the verdict arrives.

  • Live calls over a WebSocket, recordings over REST, with a regular and an asyncio client.
  • 8 kHz mono G.711 µ-law, A-law or 16-bit PCM, the way calls cross real trunks.
  • Typed errors with a retryable flag. One dependency (websockets). Python 3.10 or newer.

Get an API key at voicemaildetector.com: 500 calls a month are free.

Install

pip install voicemaildetector

A live call

Open one stream per call when it is answered, send the callee's audio as it arrives and end the stream when the call is over. The connection opens in the background; frames sent before it does are held and sent once it opens.

from voicemaildetector import VoicemailDetector

vd = VoicemailDetector()  # reads VD_API_KEY

def on_result(result):
    if result.verdict == "machine":
        hang_up()

with vd.stream(encoding="mulaw", on_result=on_result) as call:
    for frame in callee_audio():  # 20 ms frames
        call.send(frame)
# Leaving the block ends the stream and waits for the last results.

call.verdict() returns the first decision, or None if the stream ended without one; call.wait() returns once the server is done with the call; iterating over call gives every result as it comes. All three take an optional timeout in seconds.

On asyncio, send and end never block, so they fit inside a media pipeline:

from voicemaildetector import AsyncVoicemailDetector

vd = AsyncVoicemailDetector()

async with vd.stream(encoding="pcm16") as call:
    async for frame in callee_audio():
        call.send(frame)
    verdict = await call.verdict()

A call can get two results: the decision, and later an after_human machine result when a machine shows up after a human verdict, for example a greeting that starts after a pause. Keep sending audio for watch_ms after a human verdict to get it.

A recording

result = vd.detect("call-0193.wav")
print(result.verdict)  # machine

detect takes a file path, bytes or a binary file object, up to 8 MiB. A WAV file carries its own format; raw audio needs encoding.

Options

VoicemailDetector(
    api_key="vd_…",        # default: VD_API_KEY
    base_url="…",          # default: VD_API_URL, then https://api.voicemaildetector.com
    timeout=60.0,          # for detect, in seconds
    user_agent="my-dialer/2.3",
)

vd.stream(
    encoding="mulaw",          # "mulaw", "alaw" or "pcm16"; required for streams
    decision_timeout_ms=6000,  # the most audio heard before the first verdict, 1000 to 30000
    watch_ms=30000,            # how long to keep listening after a human verdict, up to 60000
    on_result=print,           # every result; a function, or a coroutine function on asyncio
    on_error=print,            # once, if the stream fails
)

detect takes the same encoding, decision_timeout_ms and watch_ms.

Results

Result(verdict="machine", stage="decision", at_ms=4500)

field values
verdict human, machine or unknown (the line stayed silent, or the audio ended first)
stage decision for the first verdict, after_human when a later result overturns human
at_ms milliseconds of audio heard, from the answer, when the result was given

Errors

Every failure is a VoicemailDetectorError with a code, the HTTP status when there was one, and retryable. On a stream it is raised by verdict(), wait() and the iteration, and passed to on_error. A dialer that must never depend on the detector carries on as if the verdict were unknown when on_error is called.

code when retryable
unauthorized the API key is missing, revoked or malformed no
payment_required the account has no calls left no
too_many_calls the account is at its limit of calls at once no
busy the API is at capacity; the next call will likely go through yes
not_ready the API is starting yes
bad_request, bad_audio, too_large the request or its audio was refused no
connection, timeout the network failed or the API did not answer in time yes
internal the API failed yes

A refused call is refused at once and never queued, so your dialer can fall back right away.

Twilio and Telnyx, without a relay

Twilio Media Streams and Telnyx media streaming can send the call's audio straight to Voicemail Detector, which posts the verdict to your app as a webhook shaped like the platform's own answering machine detection (AnsweredBy=machine_start for Twilio, call.machine.detection.ended for Telnyx). Guide: https://voicemaildetector.com/docs/twilio-telnyx

Every webhook is signed with your API key. Check it on the raw body before acting on it:

from voicemaildetector import verify_webhook

# Flask: request.get_data() is the raw body
if not verify_webhook(request.get_data(), request.headers.get("X-VD-Signature")):
    abort(401)

Examples

On Asterisk or Vicidial, the connector replaces AMD() with one line of dialplan.

More

Apache-2.0.

Metadata

Release files for voicemaildetector 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for voicemaildetector 0.2.0
File Size Uploaded Provenance Actions
voicemaildetector-0.2.0.tar.gz 20.6 kB With provenance Details for voicemaildetector-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for voicemaildetector 0.2.0
File Interpreter ABI Platform Actions
voicemaildetector-0.2.0-py3-none-any.whl Python 3 none any Details for voicemaildetector-0.2.0-py3-none-any.whl

Total release size: 38.8 kB

Release files / voicemaildetector-0.2.0.tar.gz

Download URL voicemaildetector-0.2.0.tar.gz
Size 20.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c50f521dd2fdcae5c4fb909d9fdf6849af714e9415abfcd30bf22ccd55c6e3a9
BLAKE2b-256 checksum
How to use checksums
c488259b530510899f83e41c9aac4c1443daf072db51aa8b4a713cbf4617a305
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / voicemaildetector-0.2.0-py3-none-any.whl

Download URL voicemaildetector-0.2.0-py3-none-any.whl
Size 18.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a6c08a5ec3ab3fac60d867e1e72903bb544511b1c64400d25220ee1d083bd9ae
BLAKE2b-256 checksum
How to use checksums
fa2fb910025f1b85d724199f6636885e7e6ed0ad11896a77d064c4fba94782dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Security for voicemaildetector 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for voicemaildetector-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page