silly-needle-48524
12/03/2025, 1:20 AMtall-airline-16756
12/03/2025, 1:20 AMtall-airline-16756
12/03/2025, 1:20 AMsilly-needle-48524
12/03/2025, 1:21 AMtall-airline-16756
12/03/2025, 1:21 AMsilly-needle-48524
12/03/2025, 1:24 AMtall-airline-16756
12/03/2025, 1:24 AMtranscription_node() to replace phoneme-encoded text with the readable tokens using your saved mapping, and yield new TimedString objects that keep the original `start_time`/`end_time`.
• This ensures lk.transcription carries cleaned text and useTrackTranscription on the frontend receives readable tokens with correct timing.
Example pattern (Python-like pseudocode):
replacements = {"A P I": "API", "U R L": "URL", ...}
async for chunk in text:
if isinstance(chunk, TimedString):
cleaned = chunk.text
for wrong, right in replacements.items():
cleaned = cleaned.replace(wrong, right)
yield TimedString(text=cleaned, start_time=chunk.start_time, end_time=chunk.end_time)
else:
# plain string fallback
cleaned = chunk
for wrong, right in replacements.items():
cleaned = cleaned.replace(wrong, right)
yield cleaned
2) Alternative — clean on the frontend (if you cannot change the agent)
• Use useTrackTranscription as normal, then map/replace phoneme text to readable words before rendering.
• When replacing, preserve timing by updating only the text field of each TimedString from the transcript array.
Example pattern (React/TSX pseudocode):
const transcripts = useTrackTranscription({ participantTrack });
const cleaned = transcripts.map(t => ({
...t,
text: applyMapping(t.text, replacements) // applyMapping does the string replacements
}));
return cleaned.map((t, i) => <span key={i}>{t.text}</span>);
Which approach to choose
• If you control the agent: apply changes in transcription_node() so every client gets cleaned, timed text automatically.
• If you only control the client: apply mapping in the UI before render.
If you want, share:
• a small anonymized example of the SSML you send and a TimedString you receive,
• and whether you can modify the agent code or only the frontend—
and I’ll produce a concrete agent implementation or a frontend code snippet tailored to your stack.
Sources: Text and transcriptions | LiveKit docs | Pipeline nodes and hooks | LiveKit docs | Web and mobile frontends | LiveKit docs