base_serializer

Frame serialization interfaces for Pipecat.

class pipecat.serializers.base_serializer.FrameSerializer(params: InputParams | None = None, **kwargs)[source]

Bases: BaseObject

Abstract base class for frame serialization implementations.

Defines the interface for converting frames to/from serialized formats for transmission or storage. Subclasses must implement the core serialize/deserialize methods.

class InputParams(*, ignore_rtvi_messages: bool = True)[source]

Bases: BaseModel

Base configuration parameters for FrameSerializer.

Parameters:

ignore_rtvi_messages – Whether to ignore RTVI protocol messages during serialization. Defaults to True to prevent RTVI messages from being sent to external transports.

ignore_rtvi_messages: bool
__init__(params: InputParams | None = None, **kwargs)[source]

Initialize the FrameSerializer.

Parameters:
  • params – Configuration parameters.

  • **kwargs – Additional arguments passed to BaseObject (e.g., name).

should_ignore_frame(frame: Frame) bool[source]

Check if a frame should be ignored during serialization.

This method filters out RTVI protocol messages when ignore_rtvi_messages is enabled. Subclasses can override this to add additional filtering logic.

Parameters:

frame – The frame to check.

Returns:

True if the frame should be ignored, False otherwise.

async setup(frame: StartFrame)[source]

Initialize the serializer with startup configuration.

Parameters:

frame – StartFrame containing initialization parameters.

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

Convert a frame to its serialized representation.

Parameters:

frame – The frame to serialize.

Returns:

Serialized frame data as string, bytes, or None if serialization fails.

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

Convert serialized data back to a frame object.

Parameters:

data – Serialized frame data as string or bytes.

Returns:

Reconstructed Frame object, or None if deserialization fails.