Adding support in ProtobufFrameSerializer to deserialize MessageFrame.
This commit is contained in:
@@ -41,6 +41,7 @@ class ProtobufFrameSerializer(FrameSerializer):
|
|||||||
TextFrame: "text",
|
TextFrame: "text",
|
||||||
InputAudioRawFrame: "audio",
|
InputAudioRawFrame: "audio",
|
||||||
TranscriptionFrame: "transcription",
|
TranscriptionFrame: "transcription",
|
||||||
|
MessageFrame: "message",
|
||||||
}
|
}
|
||||||
DESERIALIZABLE_FIELDS = {v: k for k, v in DESERIALIZABLE_TYPES.items()}
|
DESERIALIZABLE_FIELDS = {v: k for k, v in DESERIALIZABLE_TYPES.items()}
|
||||||
|
|
||||||
@@ -97,8 +98,18 @@ class ProtobufFrameSerializer(FrameSerializer):
|
|||||||
if "pts" in args_dict:
|
if "pts" in args_dict:
|
||||||
del args_dict["pts"]
|
del args_dict["pts"]
|
||||||
|
|
||||||
# Create the instance
|
# Special handling for MessageFrame -> TransportMessageUrgentFrame
|
||||||
instance = class_name(**args_dict)
|
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
|
# Set special fields
|
||||||
if id:
|
if id:
|
||||||
|
|||||||
Reference in New Issue
Block a user