from __future__ import annotations from pipecat.frames.frames import ( Frame, InterimTranscriptionFrame, OutputTransportMessageUrgentFrame, ) from pipecat.processors.frame_processor import FrameDirection, FrameProcessor class ProductTranscriptStreamProcessor(FrameProcessor): """Mirrors interim STT frames to the product websocket protocol.""" async def process_frame(self, frame: Frame, direction: FrameDirection) -> None: await super().process_frame(frame, direction) if isinstance(frame, InterimTranscriptionFrame): await self.push_frame( OutputTransportMessageUrgentFrame( message={ "type": "input.transcript.interim", "text": frame.text, "user_id": frame.user_id, "timestamp": frame.timestamp, } ), FrameDirection.DOWNSTREAM, ) await self.push_frame(frame, direction)