steep-balloon-41261
12/11/2025, 10:31 PMtall-airline-16756
12/11/2025, 10:31 PMtall-airline-16756
12/11/2025, 10:31 PMmodalities=["text"] and ensure no system/prompt instructions ask the model to speak.
• Keep using a separate TTS (you already use ElevenLabs). Route model responses through your TTS so you control when audio is generated.
• Add a small post-processing filter to remove or replace the placeholder before sending messages to the frontend. Example idea:
clean = message.replace("<|audio_text|>", "").strip()
Yield or send only if clean is non-empty.
If you'd like, tell me:
• which Realtime model/version you’re calling (Azure model name), and
• whether you ever set modalities to include audio or use any system prompt that asks the model to speak.
I can recommend a specific filter hook or show how to override transcription_node for your AgentSession.
Sources: Realtime model plugins | LiveKit Docs | Azure OpenAI Realtime API and LiveKit | LiveKit docs | Pipeline nodes and hooks | LiveKit docstall-airline-16756
12/11/2025, 10:33 PMtranscription_node to remove the "<|audio_text|>" placeholder. This works for SIP participants because SIP callers appear as room participants and their transcriptions flow through the same pipeline.
from livekit.agents import Agent, AgentSession
from typing import AsyncIterable
class CleanAgent(Agent):
async def transcription_node(
self, text_stream: AsyncIterable[str], model_settings=None
) -> AsyncIterable[str]:
async for delta in text_stream:
cleaned = delta.replace("<|audio_text|>", "").strip()
if cleaned: # only forward non-empty text
yield cleaned
# When creating the session (example)
session = AgentSession(
userdata=userdata,
llm=openai.realtime.RealtimeModel.with_azure(modalities=["text"]),
tts=elevenlabs.TTS(
voice_settings=VoiceSettings(
stability=0.5, similarity_boost=0.75, style=0.0, speed=1.0, use_speaker_boost=True
)
),
)
# Start the agent with your SIP-connected room context:
await session.start(agent=CleanAgent(), room=your_sip_room)
If you want different behavior, you can:
• Replace the placeholder with a custom message instead of removing it.
• Log occurrences for debugging (e.g., count placeholders per call).
• Only apply filtering for SIP participant IDs if you want it scoped.
Do you want the example scoped to only SIP participants or to include logging/counting of placeholders?
Sources: Pipeline nodes and hooks | LiveKit docs | Using Noise Cancellation for SIP and WebRTC Participantstall-airline-16756
12/11/2025, 10:36 PMtranscription_node filter prevents the <|audio_text|> placeholder from reaching your TTS.
Explanation and caveats:
• Overriding transcription_node runs before downstream components, so removing/replacing <|audio_text|> there ensures the TTS only receives cleaned text.
• The LLM may still internally generate audio events, but with modalities=["text"] and this filter in place, those audio-only tokens will not be forwarded to your ElevenLabs TTS.
• If the model sometimes emits only that placeholder (no other text), you should skip sending empty results to TTS (the example used if cleaned: for that reason).
If you want, I can:
• Provide a version that logs occurrences or
• Scope the filter so it only strips placeholders for SIP participants. Which would you prefer?tall-airline-16756
12/11/2025, 10:42 PMtranscription_node filter runs on the model's outgoing text stream (what the Agent receives/forwards), not on what you send into the LLM.
Clarifying data flow:
• Incoming audio (SIP caller) → STT → text input to the LLM.
• LLM generates a response (may include "<|audio_text|>" placeholders).
• transcription_node runs on that outgoing text stream and can remove/replace placeholders.
• The cleaned text from transcription_node is what gets forwarded to downstream components (e.g., your TTS and chat/context storage).
So the LLM still receives your original prompt/conversation history unchanged; the filter only prevents placeholder tokens from being sent onward to TTS or the user. If you want to modify what the LLM sees, you must change the input sent to the LLM (prompts, system instructions, or upstream processing).gentle-quill-48181
12/11/2025, 11:07 PMtall-airline-16756
12/11/2025, 11:07 PMfrom livekit.agents import Agent, AgentSession
from typing import AsyncIterable, Dict, Any
class NoAudioPlaceholderAgent(Agent):
async def outbound_node(
self, messages: AsyncIterable[Dict[str, Any]], model_settings=None
) -> AsyncIterable[Dict[str, Any]]:
async for msg in messages:
# Only process assistant messages with `content`
if msg.get("role") == "assistant" and "content" in msg:
# content may be a list of strings; clean each entry
cleaned_content = []
for part in msg["content"]:
cleaned = part.replace("<|audio_text|>", "").strip()
if cleaned:
cleaned_content.append(cleaned)
# if nothing remains, skip sending/speaking
if not cleaned_content:
continue
msg["content"] = cleaned_content
yield msg
Where to apply:
• Use this agent when starting the session: await session.start(agent=NoAudioPlaceholderAgent(), room=your_sip_room)
• This prevents the placeholder from being forwarded to TTS or the user and ensures only cleaned text is appended to history.
Extra safeguards (recommendations):
• Keep modalities=["text"] for the LLM.
• Log or count skipped messages so you can detect if the model frequently emits audio-only responses.
• If you want to scope filtering only for SIP participants, check the message metadata (participant id) inside outbound_node before cleaning.
Would you like this scoped to SIP-only messages or to include logging for skipped messages?