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.
  • Mono G.711 µ-law, A-law or 16-bit PCM: 8 kHz from telephone trunks, or up to 48 kHz from a browser (WebRTC) or a voice AI pipeline, at whatever rate you have it.
  • 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.

Wideband audio: WebRTC and voice AI

Browsers and voice AI pipelines usually hand you the callee's audio at 16, 24 or 48 kHz. Send it at that rate, as 16-bit PCM, and say which; the API takes care of the rest. Do not resample it yourself.

call = vd.stream(encoding="pcm16", sample_rate=16000)
call.send(frame)  # 16-bit PCM from the pipeline, at 16 kHz


# Float samples in [-1, 1] become 16-bit PCM like this:
import array

def pcm16(samples):
    return array.array("h", (int(max(-1.0, min(1.0, s)) * 32767) for s in samples)).tobytes()

In a browser, send the audio through your own server: the API key never belongs in a web page.

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 and rate; raw audio needs encoding, and sample_rate when it is not 8000.

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
    sample_rate=8000,          # Hz: 8000 (default), 11025, 12000, 16000, 22050, 24000, 32000, 44100 or 48000
    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, sample_rate, decision_timeout_ms and watch_ms. A WAV file carries its own format and rate.

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.3.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.3.0
File Size Uploaded Provenance Actions
voicemaildetector-0.3.0.tar.gz 21.4 kB With provenance Details for voicemaildetector-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 40.2 kB

Release files / voicemaildetector-0.3.0.tar.gz

Download URL voicemaildetector-0.3.0.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6f8ea5f93bfc8920a69c0ba5a7327d07ff30d89d60e1980935f61d2554fdeb27
BLAKE2b-256 checksum
How to use checksums
1941c8654e2077f36f9344a2620704d4e6290e1abd63a4993231abf9d0d410cc
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.3.0-py3-none-any.whl

Download URL voicemaildetector-0.3.0-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c04b716a290f4e5800619f13585cb042b641439baff80749655d3e671969e344
BLAKE2b-256 checksum
How to use checksums
c7bbcac988bc42a688fe8dece12740a8e73ca3f58d854e14956f788f1a1214d4
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.3.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.3.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