brave-author-62043
04/01/2026, 6:01 AMtall-airline-16756
04/01/2026, 6:02 AMtall-airline-16756
04/01/2026, 6:02 AMtranscription_node hook). Use that hook to strip or sanitize tags before sending the transcript to the client or TTS engine.
Example approach (conceptual):
1. Add a transcription processing node in your agent logic (the transcription_node).
2. For each incoming transcription delta, remove XML tags (for example with a simple regex or an XML/HTML sanitizer) and then yield the cleaned text so downstream consumers receive tag-free transcripts.
Minimal Python-style example:
import re
TAG_RE = re.compile(r'<[^>]+>')
async def transcription_node(self, text: AsyncIterable[str], model_settings) -> AsyncIterable[str]:
async for delta in text:
cleaned = TAG_RE.sub('', delta) # removes <...> tags
yield cleaned
Notes and tips:
• A regex like the one above works for simple tag removal. If transcriptions may include nested or malformed XML/SSML, consider an XML/HTML parser or sanitizer to avoid removing desirable content or breaking encoding.
• If you only need to remove specific tags (e.g., <break>, <prosody>), target those tag names instead of stripping all tags.
• This filtering affects both speech-aligned transcriptions and text-only responses if applied in the pipeline, so downstream TTS/clients will receive the sanitized text.
If you want, tell me:
• Which SDK/language you’re using (Node.js, Python, etc.), and
• Whether you want to strip all tags or only specific ones—
and I’ll provide a concrete code snippet tailored to your environment.
Sources: client-sdk-js | livekit/livekit_composite | DeepWiki | How to build an agent with speech-to-text input and text-only output | Live... | Text and transcriptions | LiveKit Documentation | Pipeline nodes and hooks | LiveKit Documentation, with interactive elementsbrave-author-62043
04/01/2026, 6:03 AMtall-airline-16756
04/01/2026, 6:03 AMfunction stripTags(text) {
return text.replace(/<[^>]+>/g, '');
}
Use this on each transcript string or incoming delta before inserting it into the DOM.
• Remove only specific tags (keeps other markup)
function removeSpecificTags(text, tags = ['break','prosody']) {
const tagList = tags.join('|');
const re = new RegExp(`<\\/?(?:${tagList})(?:\\s[^>]*)?>`, 'gi');
return text.replace(re, '');
}
Pass the tag names you want excluded so other angle-bracket content stays intact.
Important notes:
• A regex is fine for straightforward tag removal. If transcripts may contain nested/malformed XML or encoded entities, use an HTML/XML parser or sanitizer on the client (e.g., DOMParser in browsers or a library) to avoid edge cases.
• If transcripts are streamed, apply this function to each delta before appending to the UI to avoid flashes of raw tags.
• If you’re using React, run the cleaning function before setting state and avoid dangerouslySetInnerHTML unless you intentionally need raw HTML.
Tell me your frontend framework and whether transcripts are streamed or full messages, and I’ll provide a tailored code example you can drop into your UI.
, with interactive elements