|
Pipecat C++ Client SDK 1.0.0
Connect native apps to Pipecat bots
|
#include <pipecat/websocket/transport.h>
Public Member Functions | |
| WebSocketTransport (WebSocketTransportOptions options={}) | |
| Creates a transport. | |
| ~WebSocketTransport () override | |
| Disconnects if needed. | |
| WebSocketTransport (const WebSocketTransport &)=delete | |
| Transports can't be copied. | |
| WebSocketTransport & | operator= (const WebSocketTransport &)=delete |
| Transports can't be copied. | |
| void | initialize (TransportObserver *observer) override |
| Prepares the transport. | |
| void | connect (const nlohmann::json ¶ms) override |
| void | disconnect () override |
| Closes the WebSocket. | |
| void | send_ready_message (const rtvi::Message &message) override |
Sends the client-ready message. | |
| void | send_message (const rtvi::Message &message) override |
| Sends a message to the bot. | |
| size_t | max_message_size () const override |
| The largest message the bot accepts, about 1 MB. | |
| int32_t | send_user_audio (const int16_t *frames, size_t num_frames) override |
| int32_t | read_bot_audio (int16_t *frames, size_t num_frames) override |
Connects to Pipecat bots over a WebSocket.
Give it to PipecatClientOptions::transport. To connect, it needs the URL of the bot's WebSocket, and a token if the bot needs one. Start endpoints like Pipecat's development runner (python bot.py -t websocket) return both, as wsUrl and token, when asked for the websocket transport.
You can use several at the same time, e.g. one per client to talk to several bots.
|
overridevirtual |
Connects to the bot's WebSocket.
params has the URL in wsUrl (or ws_url), and the token, if the bot needs one, in token. Throws InvalidTransportParamsError if the URL is missing or isn't a WebSocket URL, and TransportStartError if connecting fails.
Implements pipecat::Transport.
|
overridevirtual |
Closes the WebSocket.
Implements pipecat::Transport.
|
overridevirtual |
Prepares the transport.
Implements pipecat::Transport.
|
overridevirtual |
The largest message the bot accepts, about 1 MB.
Reimplemented from pipecat::Transport.
|
overridevirtual |
Reads up to num_frames frames of 16-bit PCM bot audio into frames, converted to the format of the options. Waits until there's audio to read, or until the transport disconnects. Returns the number of frames read, or 0 if it disconnected.
The bot only sends audio while it speaks, and sends it faster than it plays. The transport keeps up to a minute of it, and drops what's left when the bot is interrupted, so read it as you play it.
Implements pipecat::Transport.
|
overridevirtual |
Sends a message to the bot.
Implements pipecat::Transport.
|
overridevirtual |
Sends the client-ready message.
Implements pipecat::Transport.
|
overridevirtual |
Sends num_frames frames of 16-bit PCM user audio, in the format of the options. Returns the number of frames sent.
Send the audio continuously, as it's captured, and send silence while the user is muted: the bot needs it to tell when the user stops speaking. The audio is sent as is, without echo cancellation.
Implements pipecat::Transport.