Text Filters

BaseTextFilter
base class

Base class for text preprocessing filters used by TTS services.

MarkdownTextFilter

MarkdownTextFilter
class

Removes Markdown formatting from text while preserving structure and readability.

from pipecat.utils.text import MarkdownTextFilter

text_filter = MarkdownTextFilter(
    params=MarkdownTextFilter.InputParams(
        enable_text_filter=True,
        filter_code=True,
        filter_tables=True
    )
)

Constructor Parameters

enable_text_filter
bool
default: "True"

Enable/disable text filtering

filter_code
bool
default: "False"

Remove code blocks from the text

filter_tables
bool
default: "False"

Remove Markdown tables from the text

Usage Example

from pipecat.utils.text import MarkdownTextFilter
from pipecat.services.tts import CartesiaTTSService

# Create filter with custom settings
text_filter = MarkdownTextFilter(
    params=MarkdownTextFilter.InputParams(
        enable_text_filter=True,
        filter_code=True,
        filter_tables=True
    )
)

# Use with TTS service
service = CartesiaTTSService(
    api_key="your-api-key",
    voice_id="voice-id",
    text_filter=text_filter
)