ProducerProcessor
- async pipecat.processors.producer_processor.identity_transformer(frame)[source]
- Parameters:
frame (Frame)
- class pipecat.processors.producer_processor.ProducerProcessor(*, filter, transformer=<function identity_transformer>, passthrough=True)[source]
Bases:
FrameProcessor
This class optionally passes-through received frames and decides if those frames should be sent to consumers based on a user-defined filter. The frames can be transformed into a different type of frame before being sending them to the consumers. More than one consumer can be added.
- Parameters:
filter (Callable[[Frame], Awaitable[bool]])
transformer (Callable[[Frame], Awaitable[Frame]])
passthrough (bool)
- add_consumer()[source]
Adds a new consumer and returns its associated queue.
- Returns:
The queue for the newly added consumer.
- Return type:
asyncio.Queue
- async process_frame(frame, direction)[source]
Processes an incoming frame and determines whether to produce it as a ProducerItem.
If the frame meets the produce criteria, it will be added to the consumer queues. If passthrough is enabled, the frame will also be sent to consumers.
- Parameters:
frame (Frame) – The frame to process.
direction (FrameDirection) – The direction of the frame.