Skip to content

Commit

Permalink
transports: allow sending metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
aconchillo committed Jun 6, 2024
1 parent 390582d commit db577ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/pipecat/transports/base_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from pipecat.frames.frames import (
AudioRawFrame,
CancelFrame,
MetricsFrame,
SpriteFrame,
StartFrame,
EndFrame,
Expand Down Expand Up @@ -87,6 +88,9 @@ async def stop(self):
def send_message(self, frame: TransportMessageFrame):
pass

def send_metrics(self, frame: MetricsFrame):
pass

def write_frame_to_camera(self, frame: ImageRawFrame):
pass

Expand Down Expand Up @@ -166,6 +170,8 @@ def _sink_thread_handler(self):
self._set_camera_images(frame.images)
elif isinstance(frame, TransportMessageFrame):
self.send_message(frame)
elif isinstance(frame, MetricsFrame):
self.send_metrics(frame)
else:
future = asyncio.run_coroutine_threadsafe(
self._internal_push_frame(frame), self.get_event_loop())
Expand Down
10 changes: 10 additions & 0 deletions src/pipecat/transports/services/daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Frame,
ImageRawFrame,
InterimTranscriptionFrame,
MetricsFrame,
SpriteFrame,
StartFrame,
TranscriptionFrame,
Expand Down Expand Up @@ -638,6 +639,15 @@ async def cleanup(self):
def send_message(self, frame: DailyTransportMessageFrame):
self._client.send_message(frame)

def send_metrics(self, frame: MetricsFrame):
message = DailyTransportMessageFrame(message={
"type": "pipecat-metrics",
"metrics": {
"ttfb": frame.ttfb
},
})
self._client.send_message(message)

def write_raw_audio_frames(self, frames: bytes):
self._client.write_raw_audio_frames(frames)

Expand Down

0 comments on commit db577ae

Please sign in to comment.