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
retryableflag. 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
Until the first release reaches PyPI, install it from GitHub:
pip install git+https://github.com/voicemaildetector/voicemaildetector-python.
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.
Examples
- detect_file.py: a recording.
- stream_wav.py: a WAV played as a live call.
- twilio_media_stream.py: a relay for Twilio Media Streams that hangs up on machines.
- telnyx_media_stream.py: the same for Telnyx.
On Asterisk or Vicidial, the connector replaces
AMD() with one line of dialplan.
More
- API reference: https://voicemaildetector.com/docs
- Node.js: https://github.com/voicemaildetector/voicemaildetector-node
- Security: SECURITY.md
Apache-2.0.
Metadata
Release files for voicemaildetector 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| voicemaildetector-0.1.0.tar.gz | 19.6 kB | With provenance | Details for voicemaildetector-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| voicemaildetector-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for voicemaildetector-0.1.0-py3-none-any.whl |
Total release size: 36.7 kB
Release files / voicemaildetector-0.1.0.tar.gz
| Download URL | voicemaildetector-0.1.0.tar.gz |
|---|---|
| Size | 19.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3358dc73af3827d8436fb6bc7a1c41869f9c9da2d93231cdb098116c241fe42f
|
|
BLAKE2b-256 checksum How to use checksums |
3b60b24f3cd056e8945fe5855e5db6de83f7b9ed0db9c442cbb27b8dfd7c2811
|
| 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 logRelease files / voicemaildetector-0.1.0-py3-none-any.whl
| Download URL | voicemaildetector-0.1.0-py3-none-any.whl |
|---|---|
| Size | 17.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a92e5e55afe085476b39e5376d66296b8f00f0e5bbecee996794f2bd2ba3ecb0
|
|
BLAKE2b-256 checksum How to use checksums |
b7a2c0d36cf3ae8ebf037e1b27d38c69f79d337f3ab11b0fd8f1a556c03b40ad
|
| 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 logSecurity for voicemaildetector 0.1.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.
Attestation for voicemaildetector-0.1.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 logA 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.