> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pipecat.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# SIPhon Frame Serializer

> SiphonFrameSerializer converts audio and control between Pipecat frames and the SIPhon RTP engine's media WebSocket protocol.

> [!NOTE]
>
> **Community-maintained integration.** This service is built and
> maintained by
> [siphon-project](https://github.com/siphon-project)
> . Pipecat does not test or officially support it. Please report issues and
> request changes on the
> [source repository](https://github.com/siphon-project/pipecat-siphon)
> . Learn more about
> [community integrations](https://docs.pipecat.ai/api-reference/server/services/community-integrations.md)
> .

## Overview

`SiphonFrameSerializer` converts audio and control messages between Pipecat
frames and the media WebSocket of the SIPhon RTP engine (siphon-rtp), an open
source, self-hosted RTP engine. The engine anchors a SIP call's RTP and dials
your bot's WebSocket once per call, so the bot is a server built on
`FastAPIWebsocketTransport` and never handles SIP or RTP itself.

> [card] [Source Repository](https://github.com/siphon-project/pipecat-siphon)
>
> Source code, the README, and issues for the SIPhon integration

> [card] [Example](https://github.com/siphon-project/pipecat-siphon/blob/main/examples/voice_bot.py)
>
> A complete phone bot in one file, with a compose demo that places a real SIP
> call into it

> [card] [PyPI Package](https://pypi.org/project/pipecat-siphon/)
>
> The `pipecat-siphon` package on PyPI

> [card] [SIPhon RTP Engine](https://github.com/siphon-project/siphon-rtp)
>
> The engine, its offer profiles, and the bridge protocol

> [card] [SIPhon SIP Engine](https://github.com/siphon-project/siphon-sip)
>
> SIP proxy and B2BUA, scripted in Python, that hands calls to the RTP engine

> [card] [SIPhon PBX](https://github.com/siphon-project/siphon-pbx)
>
> Extensions, queues, and call flows whose voice blocks hand calls to your bot

## Installation

This is a community-maintained package distributed separately from `pipecat-ai`:

```bash theme={null}
uv add pipecat-siphon
```

## Prerequisites

There is no account or API key. You run the SIPhon RTP engine yourself, next
to a SIP server that sends it calls, such as the
[SIPhon SIP engine](https://github.com/siphon-project/siphon-sip) (siphon-sip).
The engine bridges a call to your bot when the call's offer
profile names a WebSocket URI:

```json theme={null}
{
  "ws_uri": "ws://127.0.0.1:9001/stream",
  "ws_sample_rate": 16000,
  "ws_vad": true,
  "ws_barge_in": true
}
```

`ws_sample_rate` is the rate the bot receives and sends, any multiple of
1000 Hz from 8000 to 48000, independent of the codec on the call. `ws_vad` has
the engine report the caller's speech, and `ws_barge_in` has it drop queued bot
audio the moment the caller talks over it.

## Configuration

```python theme={null}
from pipecat_siphon import SiphonFrameSerializer
```

### SiphonFrameSerializer

**stream\_id** `str | None` (default: None)

Stream id to address control messages to before the engine's `start` message
arrives. Normally not needed: `start` is the first message on the socket and
carries the id the engine assigned.

**call\_id** `str | None` (default: None)

SIP call correlation id, for the same reason as `stream_id`.

**params** `SiphonFrameSerializer.InputParams | None` (default: None)

Serializer configuration. `None` uses `SiphonFrameSerializer.InputParams()`.
See [InputParams](#inputparams).

### InputParams

| Parameter | Type | Default | Description |
| - | - | - | - |
| `sample_rate` | `int \| None` | `None` | Pipeline input sample rate. `None` uses the `audio_in_sample_rate` the pipeline is set up with. |
| `wire_sample_rate` | `int \| None` | `None` | Wire rate assumed before the engine's `start` message arrives. `None` assumes 8000. Once `start` arrives, its rate is used. |
| `wire_ptime` | `int \| None` | `None` | Packetization time in milliseconds assumed before `start`. `None` assumes 20. |
| `speech_frames` | `Literal["vad", "user", "none"]` | `"vad"` | What the engine's speech reports become: `"vad"` emits `VADUserStartedSpeakingFrame` and `VADUserStoppedSpeakingFrame`, `"user"` emits `UserStartedSpeakingFrame` and `UserStoppedSpeakingFrame`, `"none"` ignores them. |
| `auto_interrupt` | `bool` | `True` | With `speech_frames="user"`, also emit an interruption when the caller starts speaking, because `ExternalUserTurnStartStrategy` never interrupts on its own. |
| `emit_bot_speaking_frames` | `bool` | `True` | Emit `BotStoppedSpeakingFrame` when the engine reports a playout boundary. |
| `stereo_input` | `Literal["caller", "callee", "mix", "interleaved"]` | `"caller"` | What a 2-channel uplink frame becomes: the caller's channel, the callee's, a mono mix, or a stereo frame. |
| `clear_reason` | `str` | `"barge_in"` | `reason` sent on the `clear` message an interruption produces. |
| `stop_reason` | `str` | `"pipeline_ended"` | `reason` sent on the `stop` message an `EndFrame` or `CancelFrame` produces, when the frame carries none. |
| `event_name` | `str` | `"pipecat"` | `name` of the `event` message built from a transport message that does not name itself. |

## Usage

### Serve Calls from the Engine

Each WebSocket the engine opens is one call. Build a serializer and transport
per connection, at the wire rate the offer profile asks for:

```python theme={null}
from fastapi import FastAPI, WebSocket
from pipecat.transports.websocket.fastapi import (
    FastAPIWebsocketParams,
    FastAPIWebsocketTransport,
)
from pipecat_siphon import SiphonFrameSerializer

SAMPLE_RATE = 16000

app = FastAPI()


@app.websocket("/{path:path}")
async def media(websocket: WebSocket):
    await websocket.accept()
    serializer = SiphonFrameSerializer(
        params=SiphonFrameSerializer.InputParams(
            speech_frames="vad", wire_sample_rate=SAMPLE_RATE
        ),
    )
    transport = FastAPIWebsocketTransport(
        websocket=websocket,
        params=FastAPIWebsocketParams(
            audio_in_enabled=True,
            audio_out_enabled=True,
            audio_in_sample_rate=SAMPLE_RATE,
            audio_out_sample_rate=SAMPLE_RATE,
            # One WebSocket frame per 20 ms RTP packet.
            audio_out_10ms_chunks=2,
            serializer=serializer,
        ),
    )
    ...  # Build and run the pipeline for this call.
```

See the [example](https://github.com/siphon-project/pipecat-siphon/blob/main/examples/voice_bot.py)
for the full pipeline, with Whisper, an Ollama model, and Kokoro.

### Hang Up the Call

Push an `EndFrame` (or end the worker) when the bot is done. The serializer
sends `stop`, the engine reports the bridge ended with `server_stopped`, and
your SIP server's routing hangs up the call with a BYE. The
[README](https://github.com/siphon-project/pipecat-siphon#hanging-up) shows the
routing script for the SIPhon SIP engine.

## Frames

| Frame | Sent to the engine as | Effect |
| - | - | - |
| `AudioRawFrame` | binary audio | Played to the caller at the wire rate. |
| `InterruptionFrame` | `clear` | The engine drops the bot audio it has queued. |
| `EndFrame`, `CancelFrame` | `stop` | Ends the bridge, so the SIP side can hang up. |
| `OutputTransportMessageFrame`, `OutputTransportMessageUrgentFrame` | `event` | An opaque application event, with a `name` and a `payload`. |

From the engine, caller audio becomes `InputAudioRawFrame`, speech reports
become the frames `speech_frames` selects, and DTMF becomes `InputDTMFFrame`.

## Notes

* **Wire rate**: The engine's `start` message decides the wire rate, so
  `wire_sample_rate` only covers the moment before it arrives. A rate change
  mid-call is followed in both directions.
* **No local VAD**: With `ws_vad` on and `speech_frames="vad"`, the engine
  detects the caller's turns, so the pipeline needs no VAD analyzer.
* **DTMF**: Digits `0` to `9`, `*`, and `#` become `InputDTMFFrame`. `A` to `D`
  have no `KeypadEntry`, so they are logged and dropped.
* **SIPhon PBX**: When a PBX flow hands the call to the bot, the package's
  `VoiceSession` fetches a per-call brief (instructions, who is calling, where
  the bot may transfer them) and reports the outcome back. See the
  [README](https://github.com/siphon-project/pipecat-siphon#briefed-per-call-siphon-pbx-or-your-own-session-service).

## Compatibility

Tested with `pipecat-ai` 1.17 and supported from 1.16. Check the
[changelog](https://github.com/siphon-project/pipecat-siphon/blob/main/CHANGELOG.md)
for the latest tested version.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.