Skip to main content

Overview

MarkdownTextFilter transforms Markdown-formatted text into plain text that’s suitable for text-to-speech (TTS) systems. It intelligently removes formatting elements while preserving the content structure, including proper spacing and list formatting. This filter is especially valuable for LLM-generated content, which often includes Markdown formatting that would sound unnatural if read aloud by a TTS system.

Constructor

params
InputParams
Configuration parameters for the filter

Input Parameters

Configure the filter behavior with these options:
enable_text_filter
bool
default:"True"
Whether the filter is active (when False, text passes through unchanged)
filter_code
bool
default:"False"
Whether to remove code blocks from the output
filter_tables
bool
default:"False"
Whether to remove Markdown tables from the output
filter_repeated_sequences
bool
default:"True"
Whether to remove repeated sequences of 5 or more identical characters from the output

Features

The filter handles these Markdown elements:
  • Basic Formatting: Removes *italic*, **bold**, and other formatting markers
  • Code: Removes inline code ticks and optionally removes code blocks
  • Lists: Preserves numbered lists while removing Markdown formatting
  • Tables: Optionally removes Markdown tables
  • Repeated Characters: Optionally removes sequences of 5+ repeated characters
  • Whitespace: Carefully preserves meaningful whitespace for natural speech
  • HTML: Removes HTML tags and converts entities to their plain text equivalents

Usage Examples

Basic Usage with TTS Service

Custom Configuration

Preserving Repeated Characters

What Gets Removed

Notes

  • Preserves sentence structure and readability
  • Maintains whitespace that affects speech prosody
  • Handles streaming text with partial Markdown elements
  • Efficiently converts HTML entities to plain text characters
  • Smart handling of code blocks and tables with state tracking
  • Integrates directly with TTS services in the Pipecat pipeline