base_transport: add name and id fields
This commit is contained in:
@@ -16,6 +16,7 @@ from pipecat.audio.filters.base_audio_filter import BaseAudioFilter
|
|||||||
from pipecat.audio.mixers.base_audio_mixer import BaseAudioMixer
|
from pipecat.audio.mixers.base_audio_mixer import BaseAudioMixer
|
||||||
from pipecat.audio.vad.vad_analyzer import VADAnalyzer
|
from pipecat.audio.vad.vad_analyzer import VADAnalyzer
|
||||||
from pipecat.processors.frame_processor import FrameProcessor
|
from pipecat.processors.frame_processor import FrameProcessor
|
||||||
|
from pipecat.utils.utils import obj_count, obj_id
|
||||||
|
|
||||||
|
|
||||||
class TransportParams(BaseModel):
|
class TransportParams(BaseModel):
|
||||||
@@ -46,10 +47,14 @@ class TransportParams(BaseModel):
|
|||||||
class BaseTransport(ABC):
|
class BaseTransport(ABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
input_name: str | None = None,
|
*,
|
||||||
output_name: str | None = None,
|
name: Optional[str] = None,
|
||||||
loop: asyncio.AbstractEventLoop | None = None,
|
input_name: Optional[str] = None,
|
||||||
|
output_name: Optional[str] = None,
|
||||||
|
loop: Optional[asyncio.AbstractEventLoop] = None,
|
||||||
):
|
):
|
||||||
|
self.id: int = obj_id()
|
||||||
|
self.name = name or f"{self.__class__.__name__}#{obj_count(self)}"
|
||||||
self._input_name = input_name
|
self._input_name = input_name
|
||||||
self._output_name = output_name
|
self._output_name = output_name
|
||||||
self._loop = loop or asyncio.get_running_loop()
|
self._loop = loop or asyncio.get_running_loop()
|
||||||
@@ -89,3 +94,6 @@ class BaseTransport(ABC):
|
|||||||
handler(self, *args, **kwargs)
|
handler(self, *args, **kwargs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(f"Exception in event handler {event_name}: {e}")
|
logger.exception(f"Exception in event handler {event_name}: {e}")
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|||||||
Reference in New Issue
Block a user