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_inference_triggered: Signals that enough evidence exists to start LLM inference for the current user turn. In most cases this fires together with on_user_turn_stopped. Strategies that gate finalization on the LLM (e.g. LLMTurnCompletionUserTurnStopStrategy) fire only this event upstream and a separate strategy fires on_user_turn_stopped once the LLM confirms the turn is complete.

  • on_user_turn_stopped: Signals that the user turn is semantically final. Observers, transcript appenders, and UI indicators should bind this event.

__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.

async cleanup()[source]

Cleanup the strategy.

async reset()[source]

Reset the strategy to its initial state.

Deprecated since version 1.6.0: Use handle_user_turn_started() and handle_user_turn_stopped() instead. Will be removed in 2.0.0.

A stop strategy is reset at both turn boundaries — armed on start, cleaned up on stop — so this historically ran at both. New strategies should override the boundary callbacks directly, which say plainly when the work runs, and reset however they like inside them (a private helper called from both, an extra clear() on stop, and so on).

async handle_user_turn_started()[source]

Notify the strategy that a user turn has started.

The controller calls this on every stop strategy when a turn begins. Override to run, for example, logic to arm the strategy to detect the end of the turn now in progress.

async handle_user_turn_stopped()[source]

Notify the strategy that the user turn has stopped.

The controller calls this on every stop strategy when a turn ends, regardless of which strategy (or the stop watchdog timeout) ended it. Override to run stop-specific logic — e.g. dropping a turn analyzer’s buffered speech that must not survive an externally-ended turn.

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]

Fire both on_user_turn_inference_triggered and on_user_turn_stopped.

Most strategies call this when they decide a turn has ended. To defer finalization to another strategy (so this strategy fires only the inference-triggered event), wrap this strategy with deferred() instead of changing the trigger call.

async trigger_user_turn_inference_triggered()[source]

Trigger only the on_user_turn_inference_triggered event.

async trigger_user_turn_finalized()[source]

Trigger only the on_user_turn_stopped event.