pipecat::WebSocketTransport connects your C++ app to a Pipecat bot over a WebSocket. The bot needs a WebSocket transport, like the FastAPI WebSocket transport, with Pipecat’s ProtobufFrameSerializer.
It’s part of the C++ SDK, and supports Linux (x86_64 and aarch64), macOS (aarch64) and Windows (x86_64).
Usage
Give apipecat::WebSocketTransport to the client when you create it:
- The transport connects to the bot’s WebSocket. Start endpoints like Pipecat’s development runner (
python bot.py -t websocket) return its URL, and a token if it needs one, when you ask for thewebsockettransport. If you already have them, connect directly withclient.connect({{"wsUrl", ws_url}, {"token", token}}). - The bot serializes its frames with
ProtobufFrameSerializer, like the websocket example’s bot. - Audio is 16-bit PCM, 16 kHz mono by default. Change it with
pipecat::WebSocketTransportOptions. The bot’s audio is converted to it from whatever the bot sends. The user’s audio is sent without echo cancellation, so if you play the bot through speakers, use your platform’s echo cancellation or headphones. - Each client needs its own
WebSocketTransport, and several clients can run at the same time, e.g. to talk to several bots.
Installation
Besides what the client needs, the transport uses:- libdatachannel 0.24 or newer, for its WebSocket client. CMake downloads and builds it if it’s not installed, which needs OpenSSL.
- speexdsp, to convert the bot’s audio. If it’s not installed, CMake downloads it and builds what the transport needs into it.
FetchContent, turn the transport on before making the SDK available, and link pipecat::websocket, which also links the client, see the C++ SDK overview.
To build and install it yourself, add -DPIPECAT_BUILD_WEBSOCKET=ON when configuring the SDK:
- Linux
- macOS
- Windows
OPENSSL_ROOT_DIR pointing to it).
Examples
The SDK’s text and voice examples use the WebSocket transport with--transport websocket.
Documentation
API Reference
Includes
WebSocketTransport and its optionsSource
The WebSocket transport on GitHub