abundant-father-33863
05/05/2026, 1:38 PMtall-airline-16756
05/05/2026, 1:38 PMtall-airline-16756
05/05/2026, 1:39 PMasync def stt_node(self, audio: AsyncIterable[rtc.AudioFrame], model_settings: ModelSettings) -> Optional[AsyncIterable[stt.SpeechEvent]]:
async def filtered_audio():
async for frame in audio:
yield frame
async for event in Agent.default.stt_node(self, filtered_audio(), model_settings):
if event.type == stt.SpeechEventType.FINAL_TRANSCRIPT:
text = event.alternatives[0].text
# replace word(s)
text = text.replace("badword", "goodword")
event.alternatives[0].text = text
yield event
If you’re using Deepgram STT: use the built-in replace parameter via extra_kwargs (format "find:replace"). Example snippet conceptually:
• Pass extra_kwargs={"replace":"badword:goodword"} in the STT config so Deepgram returns substituted transcripts.
If you tell me which option you want (Agent override or Deepgram), and share the language/framework (Python/Node) you’re using, I’ll provide a tailored, copy-paste-ready example.
Sources: Pipeline nodes and hooks | LiveKit Documentation, with interactive elementsabundant-father-33863
05/05/2026, 1:40 PMtall-airline-16756
05/05/2026, 1:40 PMreplace parameter, or (B) post-process transcripts in your Agent by overriding stt_node()? Tell me and I’ll give a copy-paste-ready snippet tuned to your setup.
Option A — Deepgram replace (simpler, done by provider)
• Pass extra_kwargs={"replace":"find:replace,another:swap"} in the STT config so Deepgram returns substituted transcripts.
Option B — Agent-side post-processing (more control)
• Override stt_node() and modify FINAL_TRANSCRIPT events before yielding them:
async def stt_node(self, audio: AsyncIterable[rtc.AudioFrame], model_settings: ModelSettings) -> Optional[AsyncIterable[stt.SpeechEvent]]:
async for event in Agent.default.stt_node(self, audio, model_settings):
if event.type == stt.SpeechEventType.FINAL_TRANSCRIPT:
text = event.alternatives[0].text
# Example replacements
replacements = {"badword":"goodword", "LiveKit":"Livekit"}
for find, repl in replacements.items():
text = text.replace(find, repl)
event.alternatives[0].text = text
yield event
If you want, tell me:
• which option to expand,
• whether replacements should be case-insensitive or use word boundaries,
• and an example list of words to replace — I’ll return a ready-to-run Python snippet., with interactive elements