min_words_user_turn_start_strategy

User turn start strategy based on a minimum number of words spoken by the user.

class pipecat.turns.user_start.min_words_user_turn_start_strategy.MinWordsUserTurnStartStrategy(*, min_words: int, use_interim: bool = True, **kwargs)[source]

Bases: BaseUserTurnStartStrategy

User turn start strategy based on a minimum number of words spoken by the user.

This strategy signals the start of a user turn once the user has spoken at least a specified number of words, as determined from transcription frames. Optionally, interim transcriptions can be used for earlier detection.

__init__(*, min_words: int, use_interim: bool = True, **kwargs)[source]

Initialize the minimum words bot turn start strategy.

Parameters:
  • min_words – Minimum number of spoken words required to trigger the start of a user turn.

  • use_interim – Whether to consider interim transcription frames for earlier detection.

  • **kwargs – Additional keyword arguments.

async reset()[source]

Reset the strategy to its initial state.

async process_frame(frame: Frame) ProcessFrameResult[source]

Process an incoming frame to detect the start of a user turn.

This method updates internal state based on transcription frames and triggers the user turn once the minimum word count is reached.

Parameters:

frame – The frame to be analyzed.

Returns:

STOP if the minimum word count was reached, CONTINUE otherwise.