Skip to main content

Python VoIP
Documentation | Issues | Changelog | Funding

Python VoIP

Async VoIP Python library for the AI age.

[!WARNING] This library is in early development and may contain breaking changes. Use with caution.

Sponsors

Sponsors

Usage

To get started, you will need a SIP account. One is usually included with ISP. Check your ISP's documentation or router for details.

You will need a SIP AOR (URI), which looks like this:

sip:USER:PASSWORD@SIP_SERVER

[!NOTE] This library defaults to UDP transport on port 5060 for sip: URIs, which is the most widely supported configuration. To use TCP or TLS, add an explicit transport parameter, e.g. sip:user@host;transport=TCP or sips:user@host (SIPS always uses TLS on port 5061).

CLI

A simple echo call can be started with:

uvx 'voip[cli]' sip sip:alice:********@sip.example.com echo

Each command supports an optional --dial argument to initiate an outbound call instead of waiting for an inbound one.

To dial a number, say a message, and hang up automatically:

uvx 'voip[cli]' sip sip:alice:********@sip.example.com say sip:+15551234567@sip.example.com "Your package has arrived."

You can also talk to a local agent (needs Ollama):

uvx 'voip[cli]' sip sip:alice:********@sip.example.com agent --initial-prompt "Hi, I am looking for a Mr. Ron, first name Mo?"

MCP

The voip package ships a ready-made Model Context Protocol (MCP) server that exposes tools to make phone calls on your behalf to any MCP client.

{
  "mcpServers": {
    "VoIP": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "voip[mcp]",
        "mcp"
      ],
      "env": {
        "SIP_AOR": "sip:number:password@example.com"
      }
    }
  }
}

Python API

uv add voip[audio,ai,pygments]

Subclass TranscribeCall and override transcription_received to handle results. Pass it as session_class when answering an incoming call:

import asyncio
import dataclasses

from voip.ai import TranscribeCall
from voip.sip.protocol import SIP
from voip.sip.types import SipURI
from voip.sip.transactions import InviteTransaction
from voip.rtp import RealtimeTransportProtocol
from faster_whisper import WhisperModel


@dataclasses.dataclass(kw_only=True, slots=True)
class TranscribingCall(TranscribeCall):
    def transcription_received(self, text) -> None:
        print(text)


class TranscribeInviteTransaction(InviteTransaction):
    def invite_received(self, request) -> None:
        self.ringing()
        self.answer(
            session_class=TranscribingCall,
            stt_model=WhisperModel("kyutai/stt-1b-en_fr-trfs", device="cuda"),
        )


async def main():
    loop = asyncio.get_running_loop()
    _, rtp_protocol = await loop.create_datagram_endpoint(
        RealtimeTransportProtocol,
        local_addr=("0.0.0.0", 0),
    )
    await loop.create_connection(
        lambda: SIP(
            rtp=rtp_protocol,
            aor=SipURI.parse("sip:alice:********@example.com"),
            transaction_class=TranscribeInviteTransaction,
        ),
        host="sip.example.com",
        port=5060,
    )
    await asyncio.Future()


asyncio.run(main())

For raw audio access without transcription, subclass AudioCall and override audio_received(self, audio: np.ndarray) instead.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

voip-0.5.4.tar.gz (75.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

voip-0.5.4-py3-none-any.whl (88.7 kB view details)

Uploaded Python 3

File details

Details for the file voip-0.5.4.tar.gz.

File metadata

  • Download URL: voip-0.5.4.tar.gz
  • Upload date:
  • Size: 75.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for voip-0.5.4.tar.gz
Algorithm Hash digest
SHA256 27a1853559645bced5a7db67488b815a6822137d003361b6de8cea510bc6f60e
MD5 331c36159b721ba6359132ae42d5e13c
BLAKE2b-256 780dcb203fac32880a18981dd77ea5343d654c15233aa32ddaa1ff73a483a04c

See more details on using hashes here.

Provenance

The following attestation bundles were made for voip-0.5.4.tar.gz:

Publisher: release.yml on codingjoe/VoIP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file voip-0.5.4-py3-none-any.whl.

File metadata

  • Download URL: voip-0.5.4-py3-none-any.whl
  • Upload date:
  • Size: 88.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for voip-0.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b53be65a237c347bff3d27c4e390e31d6c356a42ed854595d21bb73f2ce0d2d2
MD5 1892aeed3ca3f68f1091a974781a431d
BLAKE2b-256 de8a3970a635f504c1ac985eec5322f54fa31779a6349190230cb434f4266532

See more details on using hashes here.

Provenance

The following attestation bundles were made for voip-0.5.4-py3-none-any.whl:

Publisher: release.yml on codingjoe/VoIP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.5.4 This release

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

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