happy-fall-6105
08/26/2025, 5:32 AMtall-airline-16756
08/26/2025, 5:33 AMtall-airline-16756
08/26/2025, 5:33 AMstt_node method in your own Agent subclass. This lets you catch and adjust the transcription from the STT model before passing it along to the LLM for inference.
Here’s a simple example to get you started:
async def stt_node(self, audio: AsyncIterable[rtc.AudioFrame], model_settings: ModelSettings) -> Optional[AsyncIterable[stt.SpeechEvent]]:
# Process STT output before it goes to LLM
events = Agent.default.stt_node(self, audio, model_settings)
async def process_events():
async for event in events:
# Example: Modify the transcript text
if event.type == stt.SpeechEventType.FINAL_TRANSCRIPT:
event.alternatives[0].text = event.alternatives[0].text.replace("um", "").replace("uh", "")
yield event
return process_events()
Just to break it down:
• The stt_node method takes the audio input and runs it through the default STT processing.
• We then use a custom function to clean up the final transcript by removing filler words like "um" and "uh" before sending it off to the LLM.
• The adjusted transcription events are then passed along for whatever comes next.
This way, you have complete control over the STT output, so you can do things like clean it up, filter it, or add extra info before it moves forward. Pretty handy, right?
Sources: Pipeline nodes and hooks | LiveKit Docs | Voice pipeline nodes | LiveKit Docs