text_transformer
Stateless text transformation processor for Pipecat.
- class pipecat.processors.text_transformer.StatelessTextTransformer(transform_fn: Callable[[str], str] | Callable[[str], Coroutine[None, None, str]])[source]
Bases:
FrameProcessorProcessor that applies transformation functions to text frames.
This processor intercepts TextFrame objects and applies a user-provided transformation function to the text content. The function can be either synchronous or asynchronous (coroutine).
- __init__(transform_fn: Callable[[str], str] | Callable[[str], Coroutine[None, None, str]])[source]
Initialize the text transformer.
- Parameters:
transform_fn – Function to apply to text content. Can be synchronous (str -> str) or asynchronous (str -> Coroutine[None, None, str]).
- async process_frame(frame: Frame, direction: FrameDirection)[source]
Process frames, applying transformation to text frames.
- Parameters:
frame – The frame to process.
direction – The direction of frame flow in the pipeline.