cool-iron-91629
09/20/2025, 8:46 PMtall-airline-16756
09/20/2025, 8:46 PMtall-airline-16756
09/20/2025, 8:46 PMstt_node method in a custom Agent subclass. This way, you can tweak the transcribed text just the way you want before it moves downstream.
Here’s a friendly example in Python to get you started:
from livekit import rtc
from livekit.agents import ModelSettings, stt, Agent
from typing import AsyncIterable, Optional
async def stt_node(
self,
audio: AsyncIterable[rtc.AudioFrame],
model_settings: ModelSettings,
) -> Optional[AsyncIterable[stt.SpeechEvent]]:
# Apply default STT processing
async for event in Agent.default.stt_node(self, audio, model_settings):
# Post-process transcribed text
if event.type == stt.SpeechEventType.FINAL_TRANSCRIPT:
original_text = event.alternatives[0].text
# Example: Replace words
modified_text = original_text.replace("hello", "hi").replace("badword", "****")
event.alternatives[0].text = modified_text
yield event
For those working with Node.js, you can do something very similar by overriding the sttNode method and handling the text in the FINAL_TRANSCRIPT events.
If you’d like, I’m here to walk you through more examples or answer any questions you have. Just let me know!
Sources: Pipeline nodes and hooks | LiveKit Docs | Pipeline nodes and hooks | LiveKit Docs