base_text_filter

Base text filter interface for Pipecat text processing.

This module defines the abstract base class for text filters that can modify text content in the processing pipeline, including support for settings updates and interruption handling.

class pipecat.utils.text.base_text_filter.BaseTextFilter[source]

Bases: ABC

Abstract base class for text filters in the Pipecat framework.

Text filters are responsible for modifying text content as it flows through the processing pipeline. They support dynamic settings updates and can handle interruptions to reset their internal state.

Subclasses must implement all abstract methods to define specific filtering behavior, settings management, and interruption handling logic.

async update_settings(settings: Mapping[str, Any])[source]

Update the filter’s configuration settings.

Subclasses should implement this method to handle dynamic configuration updates during runtime, updating internal state as needed.

Parameters:

settings – Dictionary of setting names to values for configuration.

abstractmethod async filter(text: str) str[source]

Apply filtering transformations to the input text.

Subclasses must implement this method to define the specific text transformations that should be applied to the input.

Parameters:

text – The input text to be filtered.

Returns:

The filtered text after applying transformations.

async handle_interruption()[source]

Handle interruption events in the processing pipeline.

Subclasses should implement this method to reset internal state, clear buffers, or perform other cleanup when an interruption occurs.

async reset_interruption()[source]

Reset the filter state after an interruption has been handled.

Subclasses should implement this method to restore the filter to normal operation after an interruption has been processed and resolved.