From 3335629767f4da40828a00e5c5151d0678591d0e Mon Sep 17 00:00:00 2001 From: James Hush Date: Sun, 25 May 2025 11:27:25 +0800 Subject: [PATCH] This works --- examples/foundational/18b-gstreamer.py | 17 ++++++++++------- src/pipecat/services/moondream/vision.py | 1 - 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/foundational/18b-gstreamer.py b/examples/foundational/18b-gstreamer.py index c6c9b6d06..cb92c3bc1 100644 --- a/examples/foundational/18b-gstreamer.py +++ b/examples/foundational/18b-gstreamer.py @@ -37,7 +37,7 @@ from pipecat.transports.network.webrtc_connection import SmallWebRTCConnection load_dotenv(override=True) -class DebugProcessor(FrameProcessor): +class AlertProcessor(FrameProcessor): def __init__(self): super().__init__() @@ -45,9 +45,12 @@ class DebugProcessor(FrameProcessor): await super().process_frame(frame, direction) if isinstance(frame, TextFrame): - logger.info(f"DebugProcessor received text: {frame.text}") - elif isinstance(frame, EndFrame): - logger.info("DebugProcessor received end frame") + logger.info(f"Alert Processor received text: {frame.text}") + text = frame.text.strip().upper() + if text == "YES": + logger.info("Alert: YES") + else: + logger.info("Alert: NO") await self.push_frame(frame, direction) @@ -103,7 +106,7 @@ async def run_bot(webrtc_connection: SmallWebRTCConnection, args: argparse.Names ir = UserImageRequester() va = VisionImageFrameAggregator() - debug = DebugProcessor() + alert = AlertProcessor() pipeline = Pipeline( [ @@ -112,7 +115,7 @@ async def run_bot(webrtc_connection: SmallWebRTCConnection, args: argparse.Names # debug, va, moondream, - # alert_processor, # Send an email alert or something if the door is open + alert, # Send an email alert or something if the door is open transport.output(), # Transport bot output ] ) @@ -123,7 +126,7 @@ async def run_bot(webrtc_connection: SmallWebRTCConnection, args: argparse.Names DebugLogObserver( frame_types={ # TextFrame: None, - TextFrame: (MoondreamService, FrameEndpoint.DESTINATION), + TextFrame: (MoondreamService, FrameEndpoint.SOURCE), # InputImageRawFrame: None, EndFrame: None, } diff --git a/src/pipecat/services/moondream/vision.py b/src/pipecat/services/moondream/vision.py index f352c80bd..6fe44a057 100644 --- a/src/pipecat/services/moondream/vision.py +++ b/src/pipecat/services/moondream/vision.py @@ -81,6 +81,5 @@ class MoondreamService(VisionService): return description description = await asyncio.to_thread(get_image_description, frame) - logger.info(f"Image description: {description}") yield TextFrame(text=description)