Observers
RTVI Observer
Converting pipeline frames to RTVI protocol messages
The RTVIObserver
converts internal pipeline frames into RTVI protocol messages that can be consumed by clients. It acts as a bridge between Pipecat’s internal frame system and external Pipecat client SDKs.
Purpose
The RTVIObserver
serves two main purposes:
- Converting internal frames to RTVI protocol messages
- Managing state for aggregated messages (like bot transcriptions)
Frame Types Handled
The observer processes several types of frames:
Speech Events
UserStartedSpeakingFrame
→RTVIUserStartedSpeakingMessage
UserStoppedSpeakingFrame
→RTVIUserStoppedSpeakingMessage
BotStartedSpeakingFrame
→RTVIBotStartedSpeakingMessage
BotStoppedSpeakingFrame
→RTVIBotStoppedSpeakingMessage
Transcription Events
TranscriptionFrame
→RTVIUserTranscriptionMessage(final=true)
InterimTranscriptionFrame
→RTVIUserTranscriptionMessage(final=false)
LLM Events
LLMFullResponseStartFrame
→RTVIBotLLMStartedMessage
LLMFullResponseEndFrame
→RTVIBotLLMStoppedMessage
LLMTextFrame
→RTVIBotLLMTextMessage
TTS Events
TTSStartedFrame
→RTVIBotTTSStartedMessage
TTSStoppedFrame
→RTVIBotTTSStoppedMessage
TTSTextFrame
→RTVIBotTTSTextMessage
Other Events
OpenAILLMContextFrame
→RTVIUserLLMTextMessage
MetricsFrame
→RTVIMetricsMessage
Frame Deduplication
The observer uses a set to track processed frames, ensuring each frame is only processed once:
Usage
The RTVIObserver
is created and attached through the RTVI processor:
Key Features
- Frame Deduplication: Ensures each frame is processed only once
- Message Conversion: Transforms internal frames to RTVI protocol messages
- Protocol Compliance: Ensures all messages follow the RTVI protocol