Skip to main content

Python asyncio library for VoIP calls.

Project description

Python VoIP
Documentation | Issues | Changelog | Funding 💚

Python VoIP library

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

Python asyncio library for SIP telephony (RFC 3261).

All signalling uses SIP over TLS (SIPS, RFC 3261 §26) and all media is protected with SRTP (RFC 3711) using the AES_CM_128_HMAC_SHA1_80 cipher suite with SDES key exchange (RFC 4568).

Setup

pip install voip[audio,cli,pygments]

Usage

CLI

Answer calls and transcribe them live from the terminal:

voip sip transcribe sips:alice@sip.example.com --password secret

Python API

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

import asyncio
import ssl
from voip.audio import WhisperCall
from voip.sip.protocol import SIP


class MyCall(WhisperCall):
    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.1.0.tar.gz (38.5 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.1.0-py3-none-any.whl (44.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for voip-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2e8cdcda9b9fbf7a5db90637e7ada806a60b0f80060187d69657ab6fb0182349
MD5 a7409ec5fff54d675d73aef22b39ddc4
BLAKE2b-256 b1a22d3dcf4809a95af0c34fc6659f50a0aa3fa70075342966b9e6f34e96b55a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: voip-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 44.1 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 337ef34483eea649d65930b470bba8007344264c9d7bfa83b5c031be5367eece
MD5 4b7a36cfcc109f5e442c333d865cc57c
BLAKE2b-256 30916e71589e944afee0afe0647d854198f65943d34b6ad3dbd7922f55def124

See more details on using hashes here.

Provenance

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