From 6df6c16e1dfd02288f4bb2f1c7f47127b3344b6a Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Fri, 29 May 2026 16:51:51 +0800 Subject: [PATCH] Implement UserStartedSpeakingFrame handling in voice pipeline - Added support for UserStartedSpeakingFrame to enhance user interaction tracking. - Updated the pipeline to reset idle prompt count when a user starts speaking, improving responsiveness during conversations. - Integrated new event handlers for better management of user turn events and upstream frame processing. --- src/voice/pipeline.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/voice/pipeline.py b/src/voice/pipeline.py index 15e229b..a9b0bfe 100644 --- a/src/voice/pipeline.py +++ b/src/voice/pipeline.py @@ -10,6 +10,7 @@ from pipecat.frames.frames import ( LLMRunFrame, OutputTransportMessageUrgentFrame, TTSSpeakFrame, + UserStartedSpeakingFrame, ) from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner @@ -168,6 +169,7 @@ async def run_pipeline_with_serializer( ), idle_timeout_secs=config.session.inactivity_timeout_sec, ) + task.set_reached_upstream_filter((UserStartedSpeakingFrame,)) idle_prompt_count = 0 @transport.event_handler("on_client_connected") @@ -199,6 +201,11 @@ async def run_pipeline_with_serializer( logger.info(f"{client_label} websocket session timed out") await task.cancel() + @task.event_handler("on_frame_reached_upstream") + async def on_frame_reached_upstream(_task, _frame: UserStartedSpeakingFrame): + nonlocal idle_prompt_count + idle_prompt_count = 0 + @user_aggregator.event_handler("on_user_turn_started") async def on_user_turn_started(_aggregator, _strategy): nonlocal idle_prompt_count