Skip to main content

Python asyncio library for VoIP calls.

Project description

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.

Usage

CLI

Answer calls and transcribe them live from the terminal:

SIP_PASSWORD=******** uvx 'voip[cli]' sip sips:alice@sip.example.com transcribe

A simple echo server can be started with:

```console
SIP_PASSWORD=******** uvx 'voip[cli]' sip sips:alice@sip.example.com echo

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

SIP_PASSWORD=******** uvx 'voip[cli]' sip sips:alice@sip.example.com agent

Python API

uv add voip[audio,ai,pygments]

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

import asyncio
import ssl
from voip.ai import TranscribeCall
from voip.sip.protocol import SIP


class MyCall(TranscribeCall):
    def transcription_received(self, text: str) -> None:
        print(f"[{self.caller}] {text}")


class MySession(SIP):
    def call_received(self, request) -> None:
        asyncio.create_task(self.answer(request=request, call_class=MyCall))


async def main():
    loop = asyncio.get_running_loop()
    ssl_context = ssl.create_default_context()
    await loop.create_connection(
        lambda: MySession(
            aor="sips:alice@example.com",
            username="alice",
            password="secret",
        ),
        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


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.2.3.tar.gz (46.8 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.2.3-py3-none-any.whl (57.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: voip-0.2.3.tar.gz
  • Upload date:
  • Size: 46.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for voip-0.2.3.tar.gz
Algorithm Hash digest
SHA256 aa1ee1b74d25af3bd18980d6d38f48e2ea6a4615b4da4619a4dab9a519a01c1a
MD5 e6420e21ff5fbc6e2dcc90d4b216bf08
BLAKE2b-256 fe5e7d2afe69589a5de52999bbc7e57c4384a6ff79223aecae5de127d0814bff

See more details on using hashes here.

Provenance

The following attestation bundles were made for voip-0.2.3.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.2.3-py3-none-any.whl.

File metadata

  • Download URL: voip-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 57.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for voip-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 72c2d1a7622a0fe91e793b37e7a2617deb0d062ce91b7bb777d24f5efa1a7dec
MD5 9cd00f4b83194d17181a96a29e0a1c45
BLAKE2b-256 3488a79ef40df12426006870773cc45db63696a48054aea123829a91464e2359

See more details on using hashes here.

Provenance

The following attestation bundles were made for voip-0.2.3-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.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page