BaseInterruptionStrategy

class pipecat.audio.interruptions.base_interruption_strategy.BaseInterruptionStrategy[source]

Bases: ABC

This is a base class for interruption strategies. Interruption strategies decide when the user can interrupt the bot while the bot is speaking. For example, there could be strategies based on audio volume or strategies based on the number of words the user spoke.

async append_audio(audio, sample_rate)[source]

Appends audio to the strategy. Not all strategies handle audio.

Parameters:
  • audio (bytes)

  • sample_rate (int)

async append_text(text)[source]

Appends text to the strategy. Not all strategies handle text.

Parameters:

text (str)

abstractmethod async should_interrupt()[source]

This is called when the user stops speaking and it’s time to decide whether the user should interrupt the bot. The decision will be based on the aggregated audio and/or text.

Return type:

bool

abstractmethod async reset()[source]

Reset the current accumulated text and/or audio.