The RTVIObserver translates Pipecat’s internal pipeline events into standardized RTVI protocol messages. It monitors frame flow through the pipeline and generates corresponding client messages based on event types.

Purpose

The RTVIObserver serves two main functions:

  1. Converting internal pipeline frames to client-compatible RTVI messages
  2. Managing aggregated state for multi-frame events (like bot transcriptions)

Adding to a Pipeline

The observer is attached to a pipeline task along with the RTVI processor:

# Create the RTVIProcessor
rtvi = RTVIProcessor(config=RTVIConfig(config=[]))

# Add to pipeline
pipeline = Pipeline([
    transport.input(),
    rtvi,
    # Other processors...
])

# Create pipeline task with observer
task = PipelineTask(
    pipeline,
    params=PipelineParams(allow_interruptions=True),
    observers=[RTVIObserver(rtvi)],  # Add the observer here
)

Frame Translation

The observer maps Pipecat’s internal frames to RTVI protocol messages:

Pipeline FrameRTVI Message
Speech Events
UserStartedSpeakingFrameRTVIUserStartedSpeakingMessage
UserStoppedSpeakingFrameRTVIUserStoppedSpeakingMessage
BotStartedSpeakingFrameRTVIBotStartedSpeakingMessage
BotStoppedSpeakingFrameRTVIBotStoppedSpeakingMessage
Transcription
TranscriptionFrameRTVIUserTranscriptionMessage(final=true)
InterimTranscriptionFrameRTVIUserTranscriptionMessage(final=false)
LLM Processing
LLMFullResponseStartFrameRTVIBotLLMStartedMessage
LLMFullResponseEndFrameRTVIBotLLMStoppedMessage
LLMTextFrameRTVIBotLLMTextMessage
TTS Events
TTSStartedFrameRTVIBotTTSStartedMessage
TTSStoppedFrameRTVIBotTTSStoppedMessage
TTSTextFrameRTVIBotTTSTextMessage
Context/Metrics
OpenAILLMContextFrameRTVIUserLLMTextMessage
MetricsFrameRTVIMetricsMessage
RTVIServerMessageFrameRTVIServerMessage