generate_dtmf (voice/dtmf.py)

AgentLine · agentline/voice/dtmf.py · python · MIT
voice, Voice / Speech

Generates G.711 μ-law DTMF audio for IVR digit strings.

# Source: https://github.com/AgentLineHQ/AgentLine | License: MIT | Copyright 2026 AgentLine
# Provided via justclaw.it.com; keep this notice with the code.
"""
AgentLine — DTMF (Touch-Tone) Generator
Generates real DTMF (Dual-Tone Multi-Frequency) audio as G.711 μ-law bytes
ready to stream through the same <Connect><Stream> path used for TTS.

Why this exists:
  IVR phone menus ("Press 1 for sales, 2 for support") listen for DTMF tones,
  NOT spoken words. Speaking "one" into the call via TTS does nothing — the
  agent gets stuck looping the menu. This module turns a digit string like
  "1ww2" into the actual two-tone audio an IVR detector recognises.

Output format: pcm_mulaw, 8000 Hz, mono — identical to Cartesia TTS output,
so it can be fed straight into the existing provider `send_aud

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key