steep-balloon-41261
06/04/2025, 8:54 PMtall-airline-16756
06/04/2025, 8:55 PMtall-airline-16756
06/04/2025, 8:55 PMstt_node before passing it to the LLM in LiveKit, you can override the stt_node method in your custom Agent class. Here's an example of how you can achieve this:
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]]:
async def filtered_audio():
async for frame in audio:
# insert custom audio preprocessing here
yield frame
async for event in Agent.default.stt_node(self, filtered_audio(), model_settings):
# insert custom text postprocessing here
# This is where you can modify the transcript before it goes to the LLM
# For example, you could remove filler words, correct common errors, etc.
yield event
This approach allows you to:
• Preprocess the audio before it's transcribed
• Postprocess the transcribed text (in the form of speech events) before it's sent to the LLM
The stt_node is part of the STT-LLM-TTS pipeline and is responsible for converting user audio input into text that will be processed by the LLM. Let me know if you need further assistance!
Sources: Voice pipeline nodes | LiveKit Docsmillions-actor-17966
06/04/2025, 8:56 PMtall-airline-16756
06/04/2025, 8:56 PMmillions-actor-17966
06/04/2025, 8:59 PM