Overview

Pipecat services inherit from base classes that define common functionality, parameters, and methods shared across similar service types.

BaseTransport

BaseTransport
base class

Base class for transport implementations that handle audio/video I/O streams.

Constructor Parameters

input_name
Optional[str]
default: "None"

Name identifier for the input stream

output_name
Optional[str]
default: "None"

Name identifier for the output stream

loop
Optional[asyncio.AbstractEventLoop]
default: "None"

Event loop to use for async operations. Defaults to the current running loop.

Methods

input
method

Returns the input frame processor. Must be implemented by subclasses.

@abstractmethod def input(self) -> FrameProcessor
output
method

Returns the output frame processor. Must be implemented by subclasses.

@abstractmethod def output(self) -> FrameProcessor 
event_handler
decorator

Decorator to register an event handler for the specified event.

def event_handler(self, event_name: str)
add_event_handler
method

Adds an event handler function for the specified event.

def add_event_handler(self, event_name: str, handler)

TransportParams

TransportParams
class

Configuration parameters for transport audio/video capabilities.

Parameters

Video Output Configuration

camera_out_enabled
bool
default: "False"

Enable camera output

camera_out_is_live
bool
default: "False"

Whether camera output is live streaming

camera_out_width
int
default: "1024"

Camera output width in pixels

camera_out_height
int
default: "768"

Camera output height in pixels

camera_out_bitrate
int
default: "800000"

Camera output bitrate in bits/second

camera_out_framerate
int
default: "30"

Camera output framerate

camera_out_color_format
str
default: "RGB"

Camera output color format

Audio Output Configuration

audio_out_enabled
bool
default: "False"

Enable audio output

audio_out_is_live
bool
default: "False"

Whether audio output is live streaming

audio_out_sample_rate
int
default: "24000"

Audio output sample rate in Hz

audio_out_channels
int
default: "1"

Number of audio output channels

audio_out_bitrate
int
default: "96000"

Audio output bitrate in bits/second

audio_out_mixer
Optional[BaseAudioMixer]
default: "None"

Audio mixer for output processing

Audio Input Configuration

audio_in_enabled
bool
default: "False"

Enable audio input

audio_in_sample_rate
int
default: "16000"

Audio input sample rate in Hz

audio_in_channels
int
default: "1"

Number of audio input channels

audio_in_filter
Optional[BaseAudioFilter]
default: "None"

Audio filter for input processing

VAD Configuration

vad_enabled
bool
default: "False"

Enable Voice Activity Detection

vad_audio_passthrough
bool
default: "False"

When the VAD is enabled, determines whether to pass through audio frames. This is required in order to pass through audio if you’re using an STT service and have the VAD enabled.

vad_analyzer
Optional[VADAnalyzer]
default: "None"

Voice Activity Detection analyzer. You can set this to either SileroVADAnalyzer() or WebRTCVADAnalyzer().

STTService

STTService
base class

Base class for Speech-to-Text services.

Constructor Parameters

audio_passthrough
bool
default: "False"

Whether to pass through audio frames

Methods

set_model
async method

Sets the STT model.

@abstractmethod async def set_model(self, model: str)
set_language
async method

Sets the recognition language.

@abstractmethod async def set_language(self, language: Language)

LLMService

LLMService
base class

Base class for LLM services.

Methods

register_function
method

Registers a function handler. Use None as function_name to handle all functions.

def register_function( self, function_name: str | None, callback,
start_callback=None )
unregister_function
method

Removes a registered function handler.

def unregister_function(self, function_name: str | None)
has_function
method

Checks if a function handler is registered.

def has_function(self, function_name: str) -> bool
request_image_frame
async method

Requests an image from a user.

async def request_image_frame(
    self,
    user_id: str,
    *,
    text_content: str | None = None
)

TTSService

TTSService
base class

Base class for Text-to-Speech services.

Constructor Parameters

sample_rate
int
default: "24000"

Output audio sample rate in Hz

text_filter
Optional[BaseTextFilter]
default: "None"

Text filter for preprocessing

Methods

set_model
async method

Sets the TTS model.

@abstractmethod async def set_model(self, model: str)
set_voice
method

Sets the voice identifier.

@abstractmethod def set_voice(self, voice: str)
say
async method

Converts text to speech immediately.

async def say(self, text: str)

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
)

ImageGenService

ImageGenService
base class

Methods

run_image_gen
async method

Core image generation method to be implemented by services.

@abstractmethod
async def run_image_gen(self, prompt: str) -> AsyncGenerator[Frame, None]

VisionService

VisionService
base class

Base class for Vision services.

Methods

run_vision
async method

Core vision processing method to be implemented by services.

@abstractmethod
async def run_vision(
    self,
    frame: VisionImageRawFrame
) -> AsyncGenerator[Frame, None]