Remove FrameSerializerType enum and type property from serializers
This commit is contained in:
@@ -7,41 +7,18 @@
|
|||||||
"""Frame serialization interfaces for Pipecat."""
|
"""Frame serialization interfaces for Pipecat."""
|
||||||
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from enum import Enum
|
|
||||||
|
|
||||||
from pipecat.frames.frames import Frame, StartFrame
|
from pipecat.frames.frames import Frame, StartFrame
|
||||||
|
|
||||||
|
|
||||||
class FrameSerializerType(Enum):
|
|
||||||
"""Enumeration of supported frame serialization formats.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
BINARY: Binary serialization format for compact representation.
|
|
||||||
TEXT: Text-based serialization format for human-readable output.
|
|
||||||
"""
|
|
||||||
|
|
||||||
BINARY = "binary"
|
|
||||||
TEXT = "text"
|
|
||||||
|
|
||||||
|
|
||||||
class FrameSerializer(ABC):
|
class FrameSerializer(ABC):
|
||||||
"""Abstract base class for frame serialization implementations.
|
"""Abstract base class for frame serialization implementations.
|
||||||
|
|
||||||
Defines the interface for converting frames to/from serialized formats
|
Defines the interface for converting frames to/from serialized formats
|
||||||
for transmission or storage. Subclasses must implement serialization
|
for transmission or storage. Subclasses must implement the core
|
||||||
type detection and the core serialize/deserialize methods.
|
serialize/deserialize methods.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@property
|
|
||||||
@abstractmethod
|
|
||||||
def type(self) -> FrameSerializerType:
|
|
||||||
"""Get the serialization type supported by this serializer.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The FrameSerializerType indicating binary or text format.
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
async def setup(self, frame: StartFrame):
|
async def setup(self, frame: StartFrame):
|
||||||
"""Initialize the serializer with startup configuration.
|
"""Initialize the serializer with startup configuration.
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ from pipecat.frames.frames import (
|
|||||||
OutputTransportMessageUrgentFrame,
|
OutputTransportMessageUrgentFrame,
|
||||||
StartFrame,
|
StartFrame,
|
||||||
)
|
)
|
||||||
from pipecat.serializers.base_serializer import FrameSerializer, FrameSerializerType
|
from pipecat.serializers.base_serializer import FrameSerializer
|
||||||
|
|
||||||
|
|
||||||
class ExotelFrameSerializer(FrameSerializer):
|
class ExotelFrameSerializer(FrameSerializer):
|
||||||
@@ -70,15 +70,6 @@ class ExotelFrameSerializer(FrameSerializer):
|
|||||||
self._input_resampler = create_stream_resampler()
|
self._input_resampler = create_stream_resampler()
|
||||||
self._output_resampler = create_stream_resampler()
|
self._output_resampler = create_stream_resampler()
|
||||||
|
|
||||||
@property
|
|
||||||
def type(self) -> FrameSerializerType:
|
|
||||||
"""Gets the serializer type.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The serializer type, either TEXT or BINARY.
|
|
||||||
"""
|
|
||||||
return FrameSerializerType.TEXT
|
|
||||||
|
|
||||||
async def setup(self, frame: StartFrame):
|
async def setup(self, frame: StartFrame):
|
||||||
"""Sets up the serializer with pipeline configuration.
|
"""Sets up the serializer with pipeline configuration.
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ from pipecat.frames.frames import (
|
|||||||
OutputTransportMessageUrgentFrame,
|
OutputTransportMessageUrgentFrame,
|
||||||
StartFrame,
|
StartFrame,
|
||||||
)
|
)
|
||||||
from pipecat.serializers.base_serializer import FrameSerializer, FrameSerializerType
|
from pipecat.serializers.base_serializer import FrameSerializer
|
||||||
|
|
||||||
|
|
||||||
class PlivoFrameSerializer(FrameSerializer):
|
class PlivoFrameSerializer(FrameSerializer):
|
||||||
@@ -85,15 +85,6 @@ class PlivoFrameSerializer(FrameSerializer):
|
|||||||
self._output_resampler = create_stream_resampler()
|
self._output_resampler = create_stream_resampler()
|
||||||
self._hangup_attempted = False
|
self._hangup_attempted = False
|
||||||
|
|
||||||
@property
|
|
||||||
def type(self) -> FrameSerializerType:
|
|
||||||
"""Gets the serializer type.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The serializer type, either TEXT or BINARY.
|
|
||||||
"""
|
|
||||||
return FrameSerializerType.TEXT
|
|
||||||
|
|
||||||
async def setup(self, frame: StartFrame):
|
async def setup(self, frame: StartFrame):
|
||||||
"""Sets up the serializer with pipeline configuration.
|
"""Sets up the serializer with pipeline configuration.
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ from pipecat.frames.frames import (
|
|||||||
TextFrame,
|
TextFrame,
|
||||||
TranscriptionFrame,
|
TranscriptionFrame,
|
||||||
)
|
)
|
||||||
from pipecat.serializers.base_serializer import FrameSerializer, FrameSerializerType
|
from pipecat.serializers.base_serializer import FrameSerializer
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
@@ -64,15 +64,6 @@ class ProtobufFrameSerializer(FrameSerializer):
|
|||||||
"""Initialize the Protobuf frame serializer."""
|
"""Initialize the Protobuf frame serializer."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@property
|
|
||||||
def type(self) -> FrameSerializerType:
|
|
||||||
"""Get the serializer type.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
FrameSerializerType.BINARY indicating binary serialization format.
|
|
||||||
"""
|
|
||||||
return FrameSerializerType.BINARY
|
|
||||||
|
|
||||||
async def serialize(self, frame: Frame) -> str | bytes | None:
|
async def serialize(self, frame: Frame) -> str | bytes | None:
|
||||||
"""Serialize a frame to Protocol Buffer binary format.
|
"""Serialize a frame to Protocol Buffer binary format.
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ from pipecat.frames.frames import (
|
|||||||
InterruptionFrame,
|
InterruptionFrame,
|
||||||
StartFrame,
|
StartFrame,
|
||||||
)
|
)
|
||||||
from pipecat.serializers.base_serializer import FrameSerializer, FrameSerializerType
|
from pipecat.serializers.base_serializer import FrameSerializer
|
||||||
|
|
||||||
|
|
||||||
class TelnyxFrameSerializer(FrameSerializer):
|
class TelnyxFrameSerializer(FrameSerializer):
|
||||||
@@ -97,15 +97,6 @@ class TelnyxFrameSerializer(FrameSerializer):
|
|||||||
self._output_resampler = create_stream_resampler()
|
self._output_resampler = create_stream_resampler()
|
||||||
self._hangup_attempted = False
|
self._hangup_attempted = False
|
||||||
|
|
||||||
@property
|
|
||||||
def type(self) -> FrameSerializerType:
|
|
||||||
"""Gets the serializer type.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The serializer type, either TEXT or BINARY.
|
|
||||||
"""
|
|
||||||
return FrameSerializerType.TEXT
|
|
||||||
|
|
||||||
async def setup(self, frame: StartFrame):
|
async def setup(self, frame: StartFrame):
|
||||||
"""Sets up the serializer with pipeline configuration.
|
"""Sets up the serializer with pipeline configuration.
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ from pipecat.frames.frames import (
|
|||||||
OutputTransportMessageUrgentFrame,
|
OutputTransportMessageUrgentFrame,
|
||||||
StartFrame,
|
StartFrame,
|
||||||
)
|
)
|
||||||
from pipecat.serializers.base_serializer import FrameSerializer, FrameSerializerType
|
from pipecat.serializers.base_serializer import FrameSerializer
|
||||||
|
|
||||||
|
|
||||||
class TwilioFrameSerializer(FrameSerializer):
|
class TwilioFrameSerializer(FrameSerializer):
|
||||||
@@ -116,15 +116,6 @@ class TwilioFrameSerializer(FrameSerializer):
|
|||||||
self._output_resampler = create_stream_resampler()
|
self._output_resampler = create_stream_resampler()
|
||||||
self._hangup_attempted = False
|
self._hangup_attempted = False
|
||||||
|
|
||||||
@property
|
|
||||||
def type(self) -> FrameSerializerType:
|
|
||||||
"""Gets the serializer type.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The serializer type, either TEXT or BINARY.
|
|
||||||
"""
|
|
||||||
return FrameSerializerType.TEXT
|
|
||||||
|
|
||||||
async def setup(self, frame: StartFrame):
|
async def setup(self, frame: StartFrame):
|
||||||
"""Sets up the serializer with pipeline configuration.
|
"""Sets up the serializer with pipeline configuration.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user