protobuf

Protobuf frame serialization for Pipecat.

class pipecat.serializers.protobuf.MessageFrame(data: str)[source]

Bases: object

Data class for converting transport messages into Protobuf format.

Parameters:

data – JSON-encoded message data for transport.

data: str
class pipecat.serializers.protobuf.ProtobufFrameSerializer(params: InputParams | None = None)[source]

Bases: FrameSerializer

Serializer for converting Pipecat frames to/from Protocol Buffer format.

Provides efficient binary serialization for frame transport over network connections. Supports text, audio, transcription, and message frames with automatic conversion between transport message types.

SERIALIZABLE_TYPES = {<class 'pipecat.frames.frames.OutputAudioRawFrame'>: 'audio', <class 'pipecat.frames.frames.TextFrame'>: 'text', <class 'pipecat.frames.frames.TranscriptionFrame'>: 'transcription', <class 'pipecat.serializers.protobuf.MessageFrame'>: 'message'}
SERIALIZABLE_FIELDS = {'audio': <class 'pipecat.frames.frames.OutputAudioRawFrame'>, 'message': <class 'pipecat.serializers.protobuf.MessageFrame'>, 'text': <class 'pipecat.frames.frames.TextFrame'>, 'transcription': <class 'pipecat.frames.frames.TranscriptionFrame'>}
DESERIALIZABLE_TYPES = {<class 'pipecat.frames.frames.InputAudioRawFrame'>: 'audio', <class 'pipecat.frames.frames.TextFrame'>: 'text', <class 'pipecat.frames.frames.TranscriptionFrame'>: 'transcription', <class 'pipecat.serializers.protobuf.MessageFrame'>: 'message'}
DESERIALIZABLE_FIELDS = {'audio': <class 'pipecat.frames.frames.InputAudioRawFrame'>, 'message': <class 'pipecat.serializers.protobuf.MessageFrame'>, 'text': <class 'pipecat.frames.frames.TextFrame'>, 'transcription': <class 'pipecat.frames.frames.TranscriptionFrame'>}
__init__(params: InputParams | None = None)[source]

Initialize the Protobuf frame serializer.

Parameters:

params – Configuration parameters.

async serialize(frame: Frame) str | bytes | None[source]

Serialize a frame to Protocol Buffer binary format.

Parameters:

frame – The frame to serialize.

Returns:

Serialized frame as bytes, or None if frame type is not serializable.

async deserialize(data: str | bytes) Frame | None[source]

Deserialize Protocol Buffer binary data to a frame.

Parameters:

data – Binary protobuf data to deserialize.

Returns:

Deserialized frame instance, or None if deserialization fails.