Documentation |
Issues |
Changelog |
Funding ♥
Async VoIP Python library for the AI age.
Warning
This library is in early development and may contain breaking changes. Use with caution.
Answer calls and transcribe them live from the terminal:
SIP_PASSWORD=******** uvx 'voip[cli]' sip sips:alice@sip.example.com transcribeA simple echo server can be started with:
```console
SIP_PASSWORD=******** uvx 'voip[cli]' sip sips:alice@sip.example.com echoYou can also talk to a local agent (needs Ollama):
SIP_PASSWORD=******** uvx 'voip[cli]' sip sips:alice@sip.example.com agentuv add voip[audio,ai,pygments]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.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.