base_user_turn_stop_strategy

Base user turn stop strategy for determining when the user stopped speaking.

class pipecat.turns.user_stop.base_user_turn_stop_strategy.UserTurnStoppedParams(enable_user_speaking_frames: bool)[source]

Bases: object

Parameters emitted when a user turn stops.

These parameters are passed to the on_user_turn_stopped event and provide contextual information about how the end of user turn should be handled by the user aggregator.

Parameters:

enable_user_speaking_frames – Whether the user aggregator should emit frames indicating user speaking state (e.g., user stopped speaking). This is typically enabled by default, but may be disabled when another component (such as an STT service) is already responsible for generating user speaking frames.

enable_user_speaking_frames: bool
class pipecat.turns.user_stop.base_user_turn_stop_strategy.BaseUserTurnStopStrategy(*, enable_user_speaking_frames: bool = True, **kwargs)[source]

Bases: BaseObject

Base class for strategies that determine when the user stops speaking.

Subclasses should implement logic to detect when the user stops speaking. This could be based on analyzing incoming frames (such as transcriptions), conversation state, or other heuristics.

Events triggered by strategies:

  • on_push_frame: Indicates the strategy wants to push a frame.

  • on_user_turn_stopped: Signals that the user stopped speaking.

__init__(*, enable_user_speaking_frames: bool = True, **kwargs)[source]

Initialize the base user turn stop strategy.

Parameters:
  • enable_user_speaking_frames – If True, the aggregator will emit frames indicating when the user stops speaking. This is enabled by default, but you may want to disable it if another component (e.g., an STT service) is already generating these frames.

  • **kwargs – Additional keyword arguments.

property task_manager: BaseTaskManager

Returns the configured task manager.

async setup(task_manager: BaseTaskManager)[source]

Initialize the strategy with the given task manager.

Parameters:

task_manager – The task manager to be associated with this instance.

async cleanup()[source]

Cleanup the strategy.

async reset()[source]

Reset the strategy to its initial state.

async process_frame(frame: Frame) ProcessFrameResult | None[source]

Process an incoming frame to decide whether the user stopped speaking.

Subclasses should override this to implement logic that decides whether the user has stopped speaking.

Parameters:

frame – The frame to be analyzed.

Returns:

A ProcessFrameResult indicating the outcome, or None (treated as CONTINUE for backward compatibility).

async push_frame(frame: Frame, direction: FrameDirection = FrameDirection.DOWNSTREAM)[source]

Emit on_push_frame to push a frame using the user aggreagtor.

Parameters:
  • frame – The frame to be pushed.

  • direction – What direction the frame should be pushed to.

async broadcast_frame(frame_cls: type[Frame], **kwargs)[source]

Emit on_broadcast_frame to broadcast a frame using the user aggreagtor.

Parameters:
  • frame_cls – The class of the frame to be broadcasted.

  • **kwargs – Keyword arguments to be passed to the frame’s constructor.

async trigger_user_turn_stopped()[source]

Trigger the on_user_turn_stopped event.