Stream real-time audio between Pipecat and Wavix using WebSockets.
pipecat-wavix converts audio between Pipecat frames and the Wavix media stream format so you can build voice-enabled applications quickly.
This repository contains the source code for the Wavix Frame Serializer for Pipecat.
It lets you stream audio between Pipecat and Wavix by converting audio data between their formats in real time.
This project includes:
-
WavixFrameSerializer Converts audio between Pipecat frames and the Wavix WebSocket media stream format.
-
bot.py A minimal example that runs a Pipecat development bot and connects to a Wavix media stream. Use this if you want full control over call handling.
-
server.py A complete example that handles the full Wavix call flow, including webhooks, call answering, and media streaming. Use this if you want a ready-to-run setup with minimal configuration.
Use this project if you want to:
- Build voice applications with Pipecat and Wavix
- Stream real-time audio over WebSockets
- Prototype or test telephony integration
Wavix uses the following audio format:
- Format: PCM16
- Sample rate: 24 kHz
- Bit depth: 16-bit
- Frame size: 20 ms
- Channels: mono
- Endianness: little-endian
Before you start, make sure you have:
- A Wavix account: https://docs.wavix.com/getting-started/create-account
- A Wavix phone number
Set these environment variables:
WAVIX_API_KEY– your Wavix API keyOPENAI_API_KEY– your OpenAI API keyDEEPGRAM_API_KEY– your Deepgram API keyCARTESIA_API_KEY– your Cartesia API key
- Python 3.12
uvpackage manager- ngrok (for local development)
Install the package:
pip install pipecat-wavixIf you use uv, add it to your pyproject.toml:
[project]
dependencies = [
"pipecat-wavix>=1.1.0"
]Then install dependencies:
uv syncImport the serializer:
from pipecat_wavix import WavixFrameSerializerConfigure it:
WAVIX_SAMPLE_RATE = 24000
BOT_SAMPLE_RATE = 16000
serializer = WavixFrameSerializer(
stream_id=stream_id,
params=WavixFrameSerializer.InputParams(
wavix_sample_rate=WAVIX_SAMPLE_RATE,
sample_rate=BOT_SAMPLE_RATE,
audio_track="inbound",
),
)Set up the transport:
transport = FastAPIWebsocketTransport(
websocket=websocket,
params=FastAPIWebsocketParams(
audio_in_enabled=True,
audio_in_passthrough=True,
audio_in_sample_rate=BOT_SAMPLE_RATE,
audio_out_enabled=True,
audio_out_sample_rate=WAVIX_SAMPLE_RATE,
add_wav_header=False,
serializer=serializer,
audio_out_10ms_chunks=2,
fixed_audio_packet_size=960,
),
)Outbound audio is automatically converted to Wavix’s required format: PCM16, 24 kHz, mono, little-endian, 20 ms frames.
Use server.py to handle the full Wavix call flow.
Run:
uv run server.pyThe server:
-
Starts a FastAPI app
-
Opens an ngrok tunnel
-
Exposes:
POST /wavix/inbound(webhook)GET /health(health check)WS /ws(WebSocket for media stream)
When a call reaches your Wavix number, the server:
- Answers the call
- Starts bidirectional streaming to
/ws - Launches the bot from
bot.py
The server prints:
- Local URL (for example,
http://localhost:7860) - Public ngrok URL
- Webhook URL (
https://.../wavix/inbound) - WebSocket URL (
wss://.../ws)
Set your Wavix number’s voice webhook to:
https://your-public-url/wavix/inbound
To update your number:
- Sign in to your Wavix account.
- Go to Numbers & trunks > My numbers.
- Select your number.
- Choose Edit number.
- Paste the webhook URL.
- Select Save.
Then call your number. The server handles the rest.
- Don’t start ngrok manually in this mode.
- Don’t call Wavix APIs manually —
server.pyhandles everything.
Use bot.py if you want to run the Pipecat development runner and manage Wavix calls yourself.
- Starts the Pipecat development runner
- Accepts a WebSocket connection
- Parses the Wavix handshake
- Builds the audio pipeline
- Doesn’t answer calls
- Doesn’t create streams
- Doesn’t replace
server.py
uv run bot.py --transport wavix --proxy your-public-hostnameExample:
uv run bot.py --transport wavix --proxy your-ngrok-url.ngrok-free.devStart ngrok in a separate terminal:
ngrok http 7860Use the ngrok hostname as the --proxy value (don’t include https://, unless required).
In this mode, you must handle call control yourself.
-
Get the
call_idfrom Wavix webhooks https://docs.wavix.com/api-reference/call-webhooks/on-call-event -
Answer the call:
curl -L "https://api.wavix.com/v1/calls/$CALL_ID/answer" \
-H "Authorization: Bearer $WAVIX_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'- Start streaming:
curl -L "https://api.wavix.com/v1/calls/$CALL_ID/streams" \
-H "Authorization: Bearer $WAVIX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"stream_url": "wss://your-public-hostname/ws",
"stream_type": "twoway",
"stream_channel": "inbound"
}'Use server.py if you want:
- A complete, ready-to-run setup
- Automatic webhook handling
- Minimal configuration
Use bot.py if you want:
- Full control over call handling
- Integration with your own backend
- A development or testing setup