Python asyncio library for VoIP calls.
Project description
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
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 explicittransportparameter, e.g.sip:user@host;transport=TCPorsips: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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file voip-0.5.3.tar.gz.
File metadata
- Download URL: voip-0.5.3.tar.gz
- Upload date:
- Size: 64.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0039dde065bb253e910fcfb1adbb081a3fa95ff3baccfef23696c8facd10b23e
|
|
| MD5 |
eae376d7ed8845956cb6bcab959c32cd
|
|
| BLAKE2b-256 |
5bf88ce330c0b63cc2045fe55db0109a6777ecdf84d7169f76e3eca64beb4c23
|
Provenance
The following attestation bundles were made for voip-0.5.3.tar.gz:
Publisher:
release.yml on codingjoe/VoIP
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
voip-0.5.3.tar.gz -
Subject digest:
0039dde065bb253e910fcfb1adbb081a3fa95ff3baccfef23696c8facd10b23e - Sigstore transparency entry: 1924143562
- Sigstore integration time:
-
Permalink:
codingjoe/VoIP@53ca27593a648470123d8c0b5079654d60d5f2bc -
Branch / Tag:
refs/tags/0.5.3 - Owner: https://github.com/codingjoe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@53ca27593a648470123d8c0b5079654d60d5f2bc -
Trigger Event:
release
-
Statement type:
File details
Details for the file voip-0.5.3-py3-none-any.whl.
File metadata
- Download URL: voip-0.5.3-py3-none-any.whl
- Upload date:
- Size: 77.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e8a1aa6cce41c5c646c668ac9f34a8b2e8cdd5fa4b903893be26dfbcbcc6783
|
|
| MD5 |
a1cf5f0826bfea44f376c8e76b2444e2
|
|
| BLAKE2b-256 |
1ded62c5c36fbaadc1451d00948824e008675c3f9ae1327ccafdfd16bb9b250c
|
Provenance
The following attestation bundles were made for voip-0.5.3-py3-none-any.whl:
Publisher:
release.yml on codingjoe/VoIP
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
voip-0.5.3-py3-none-any.whl -
Subject digest:
8e8a1aa6cce41c5c646c668ac9f34a8b2e8cdd5fa4b903893be26dfbcbcc6783 - Sigstore transparency entry: 1924144190
- Sigstore integration time:
-
Permalink:
codingjoe/VoIP@53ca27593a648470123d8c0b5079654d60d5f2bc -
Branch / Tag:
refs/tags/0.5.3 - Owner: https://github.com/codingjoe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@53ca27593a648470123d8c0b5079654d60d5f2bc -
Trigger Event:
release
-
Statement type: