abundant-finland-34492
11/18/2025, 9:29 AMtall-airline-16756
11/18/2025, 9:29 AMtall-airline-16756
11/18/2025, 9:29 AMstt_node() method. This lets you process raw audio into text using your STT engine, returning a stream of transcription events.
• Custom LLM Integration: Next, override the llm_node() method to send prompts to your LLM backend. Just make sure the output matches the expected stream format.
• Custom TTS Integration: Finally, override the tts_node() method to create speech from text with your TTS engine, producing an audio frame stream.
To give you a clearer picture, here’s an example in Python showing how you might define these methods in your custom agent class:
class CustomAgent(Agent):
async def stt_node(self, audio, model_settings):
async for transcript in my_stt_engine(audio):
yield transcript
async def llm_node(self, chat_ctx, tool_ctx, model_settings):
response = await my_llm_api(chat_ctx.messages)
yield llm.ChatChunk(text=response)
async def tts_node(self, text, model_settings):
full_text = ''.join([t async for t in text])
async for frame in my_tts_engine(full_text):
yield frame
This approach works wonderfully in both JavaScript and Python SDKs. If you have any questions or need a hand with anything else, please don’t hesitate to reach out—I’m here to help!
Sources: Pipeline nodes and hooks | LiveKit docs | Agents v0.x migration guide - Node.js | LiveKit Docs | plugins/test/src/index.ts | livekit-agents/livekit/agents/voice/agent.py