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.
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;transport=TCP
[!NOTE] This library uses secure defaults (TLS transport on port 5061). However, most SIP servers only support unencrypted connections. Therefore, you will need to provide an explict transport parameter.
CLI
A simple echo call can be started with:
uvx 'voip[cli]' sip sips: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 sips: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 sips:alice:********@sip.example.com agent --initial-prompt "Hi, I am looking for a Mr. Ron, first name Mo?"
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
import ssl
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),
)
ssl_context = ssl.create_default_context()
await loop.create_connection(
lambda: SIP(
rtp=rtp_protocol,
aor=SipURI.parse("sips:alice:********@example.com"),
transaction_class=TranscribeInviteTransaction,
),
host="sip.example.com",
port=5061,
ssl=ssl_context,
)
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.1.tar.gz.
File metadata
- Download URL: voip-0.5.1.tar.gz
- Upload date:
- Size: 61.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cedc7838a6d7537746955d684bc8942f5ef487d46740fd2677ab3ef93e44ffb
|
|
| MD5 |
75a8216f53688527c4adfb9f6ba8a99d
|
|
| BLAKE2b-256 |
3d55884ba533efe706bdbba44b2a8c606767cd848721ba3516eec8840ad1fd8d
|
Provenance
The following attestation bundles were made for voip-0.5.1.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.1.tar.gz -
Subject digest:
2cedc7838a6d7537746955d684bc8942f5ef487d46740fd2677ab3ef93e44ffb - Sigstore transparency entry: 1397515062
- Sigstore integration time:
-
Permalink:
codingjoe/VoIP@815b0e52806667f3f5a28e8dda95f37f16de463d -
Branch / Tag:
refs/tags/0.5.1 - Owner: https://github.com/codingjoe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@815b0e52806667f3f5a28e8dda95f37f16de463d -
Trigger Event:
release
-
Statement type:
File details
Details for the file voip-0.5.1-py3-none-any.whl.
File metadata
- Download URL: voip-0.5.1-py3-none-any.whl
- Upload date:
- Size: 74.4 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 |
4eb43f9cff776f2d8d07267864afcac304a8395528c433436924240efd45c510
|
|
| MD5 |
04d8ccc049b720a5f82e58735a68c9fb
|
|
| BLAKE2b-256 |
2dcf806d95c951ce5e5110d1dde776a1fb8becc68022cf66df788581cce26e19
|
Provenance
The following attestation bundles were made for voip-0.5.1-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.1-py3-none-any.whl -
Subject digest:
4eb43f9cff776f2d8d07267864afcac304a8395528c433436924240efd45c510 - Sigstore transparency entry: 1397515072
- Sigstore integration time:
-
Permalink:
codingjoe/VoIP@815b0e52806667f3f5a28e8dda95f37f16de463d -
Branch / Tag:
refs/tags/0.5.1 - Owner: https://github.com/codingjoe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@815b0e52806667f3f5a28e8dda95f37f16de463d -
Trigger Event:
release
-
Statement type: