From 028650249cefe3c9b785aa2cdab8f0d3d0acf5d1 Mon Sep 17 00:00:00 2001 From: Filipi Fuchter Date: Fri, 6 Jun 2025 17:07:39 -0300 Subject: [PATCH] Adding support in ProtobufFrameSerializer to deserialize MessageFrame. --- src/pipecat/serializers/protobuf.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/pipecat/serializers/protobuf.py b/src/pipecat/serializers/protobuf.py index c3b6d86af..c91c6661e 100644 --- a/src/pipecat/serializers/protobuf.py +++ b/src/pipecat/serializers/protobuf.py @@ -41,6 +41,7 @@ class ProtobufFrameSerializer(FrameSerializer): TextFrame: "text", InputAudioRawFrame: "audio", TranscriptionFrame: "transcription", + MessageFrame: "message", } DESERIALIZABLE_FIELDS = {v: k for k, v in DESERIALIZABLE_TYPES.items()} @@ -97,8 +98,18 @@ class ProtobufFrameSerializer(FrameSerializer): if "pts" in args_dict: del args_dict["pts"] - # Create the instance - instance = class_name(**args_dict) + # Special handling for MessageFrame -> TransportMessageUrgentFrame + if class_name == MessageFrame: + try: + msg = json.loads(args_dict["data"]) + instance = TransportMessageUrgentFrame(message=msg) + logger.debug(f"ProtobufFrameSerializer: Transport message {instance}") + except Exception as e: + logger.error(f"Error parsing MessageFrame data: {e}") + return None + else: + # Normal deserialization, create the instance + instance = class_name(**args_dict) # Set special fields if id: