proud-lawyer-39815
11/29/2025, 7:42 AMtall-airline-16756
11/29/2025, 7:42 AMtall-airline-16756
11/29/2025, 7:42 AMtranscription_node to map spoken/phonetic expansions back to their original terms before sending the transcript to the frontend. Example approach:
1. Capture transcription chunks in transcription_node.
2. Replace phonetic/expanded forms with the desired written terms (e.g., "A P I" → "API").
3. Yield the cleaned text for the transcript stream.
If you'd like, share one or two example pronunciations you use (how they appear in the transcript now and how you want them displayed) and I’ll provide a ready-to-drop-in transcription_node snippet.
Sources: Cartesia TTS plugin guide | LiveKit docs | Speechify TTS plugin guide | LiveKit Docs | ElevenLabs TTS plugin guide | LiveKit Docs | Resemble AI TTS plugin guide | LiveKit Docs | Speechmatics STT plugin guide | LiveKit Docsproud-lawyer-39815
12/01/2025, 1:55 PMtall-airline-16756
12/01/2025, 1:56 PMtranscription_node example that replaces "A P I" with "API" before yielding transcripts, plus brief integration notes.
# async transcription_node example
async def transcription_node(self, text: AsyncIterable[str], model_settings: ModelSettings):
replacements = {
"A P I": "API",
# add more mappings as needed
}
async for chunk in text:
cleaned = chunk
for spoken, written in replacements.items():
cleaned = cleaned.replace(spoken, written)
yield cleaned
Integration notes:
• Place this method in your agent class that implements the transcription pipeline.
• Add any other pronunciation→term pairs to replacements.
• This runs after STT produces text and before transcripts are sent to the frontend, so TTS pronunciation can remain unchanged while transcripts show the original term.
Would you like the snippet adapted for a specific language, casing rules, or regex-based matching?proud-lawyer-39815
12/01/2025, 6:21 PMtall-airline-16756
12/01/2025, 6:21 PMtts_node and/or injecting SSML/phoneme tags before sending it to the TTS provider.
What you can do (options):
• Use tts_node to modify text only for audio:
a. Read the transcript text stream in tts_node.
b. Replace target tokens with pronunciation-friendly forms (e.g., "API" → "A P I") or insert SSML around the token.
c. Pass the modified stream to the provider's TTS call — the transcript remains unchanged.
• Use SSML / phoneme tags (provider-dependent):
◦ Wrap terms with <phoneme> (or provider-specific phoneme syntax) to specify IPA or phonetic spelling while leaving the visible transcript as the original word.
◦ Ensure the chosen TTS provider supports SSML/phoneme and enable SSML parsing if required.
Quick example patterns
1) Simple text-replace in tts_node (keeps transcript unchanged):
# pseudocode
async def tts_node(self, text_stream, model_settings):
async for chunk in text_stream:
modified = chunk.replace("API", "A P I")
yield from synthesize(modified)
2) SSML injection for precise pronunciation:
# send as SSML (provider must accept SSML)
<speak>We support <phoneme alphabet="ipa" ph="eɪ pi aɪ">API</phoneme> in our API.</speak>
Provider notes:
• ElevenLabs, Google Cloud, Azure, AWS Polly, and others support SSML/phoneme (may require enabling SSML parsing).
• Use provider-specific docs for exact tag syntax and any config flags.
If you want, I can:
• Provide a ready-to-drop-in tts_node snippet for your agent runtime (Node or Python).
• Show the exact SSML format for a specific TTS provider you use. Which language/runtime and TTS provider are you using? Sources: Agent speech and audio | LiveKit docs | Agents v0.x migration guide - Node.js | LiveKit Docs | ElevenLabs TTS plugin guide | LiveKit Docs | Google Cloud TTS integration guide | LiveKit Docs | Azure Speech TTS plugin guide | LiveKit Docsproud-lawyer-39815
12/01/2025, 6:25 PMtall-airline-16756
12/01/2025, 6:25 PMsynthesize as a short placeholder. It represents the TTS call that takes the (possibly modified) text/SSML and produces audio frames for playback. In your agent that call can be one of:
• Your TTS provider client call (e.g., ElevenLabs/Google/Azure/AWS SDK) that accepts text or SSML and returns audio bytes/stream.
• The LiveKit agent helper: voice.Agent.default.ttsNode(...) (or your runtime’s built-in ttsNode) which forwards text to the configured provider and returns a readable audio stream.
What synthesize does (purpose):
• Sends the modified text/SSML to the TTS provider.
• Receives audio frames/bytes or a streaming audio source.
• Returns or yields that audio so it can be sent to participants or saved.
If you tell me your runtime (Node/Python) and which TTS provider you use, I’ll give a concrete tts_node example that calls the exact synth function for that provider.proud-lawyer-39815
12/01/2025, 6:26 PMtall-airline-16756
12/01/2025, 6:26 PMreplace calls are case-sensitive.
How to make them case-insensitive:
• JavaScript / TypeScript (regex with i flag):
const replaced = text.replace(/api/gi, "API");
Use g to replace all occurrences and i for case-insensitive matching.
• Python (re with re.IGNORECASE):
import re
replaced = re.sub(r"api", "API", text, flags=re.IGNORECASE)
Notes:
• If you need to preserve original casing patterns (e.g., "Api" → "API" vs "api" → "API"), tell me the desired rules and I’ll provide code that preserves or normalizes casing.proud-lawyer-39815
12/01/2025, 7:23 PMtall-airline-16756
12/01/2025, 7:23 PMtranscription_node isn't being activated on the first agent utterance.
A few quick checks that commonly fix this:
• Confirm transcription_node is implemented on your Agent subclass (not a standalone function) and includes logging so you can see when it runs.
• If your agent’s first speech is triggered with session.say(...), try generating the reply via await session.generate_reply(...) instead so the output flows through the normal LLM → TTS → pipeline (this ensures transcription_node runs).
• Ensure the AgentSession is fully initialized before sending the first utterance — if speech is sent during startup the node may not be registered yet.
• If you rely on TTS provider direct-playback or pre-synthesized audio, that can bypass `transcription_node`; use the agent’s `tts_node`/default TTS path instead.
To debug quickly, add these logs and share them if you want:
• Log entry at start of transcription_node
• Log when you call session.say / generate_reply
• Any agent state transitions or errors during startup
If you can paste the small snippet that defines your Agent subclass and how you trigger the first speech (3–8 lines around initialization and the first speak call), I’ll point out exactly what to change.
Sources: Agent speech and audio | LiveKit docs | Pipeline nodes and hooks | LiveKit docs | Text and transcriptions | LiveKit docs | Events and error handling | LiveKit docsproud-lawyer-39815
12/01/2025, 7:36 PMtall-airline-16756
12/01/2025, 7:36 PMuse_tts_aligned_transcript, that explains the behavior. With alignment enabled, the pipeline emits timed TimedString objects (word-level timing) from supported TTS providers, and the transcription_node runs when aligned data is produced. Common causes for it not firing on the first utterance:
• The first utterance is synthesized or played before the session and nodes are fully initialized.
• Your TTS provider for the first utterance doesn’t produce alignment data (only Cartesia and ElevenLabs provide word-level alignment).
• The initial speech is produced via a direct-play shortcut (e.g., pre-synthesized audio or a session.say() path that bypasses the usual TTS pipeline).
What to try next (quick checklist):
• Ensure AgentSession is fully initialized before speaking.
• Replace session.say(...) for the first reply with await session.generate_reply(...) so output flows through LLM → tts_node → transcription_node.
• Add logging at the top of transcription_node, tts_node, and after session init to observe ordering.
• If your provider doesn’t support alignment, set use_tts_aligned_transcript=False or accept sentence-level transcripts for the first utterance.
If you’d like, paste:
• The Agent subclass definition (the transcription_node / tts_node methods), and
• The 5–10 lines where you initialize AgentSession and trigger the first speech
—and I’ll point out the minimal change to ensure transcription_node runs on the initial utterance.
Sources: Text and transcriptions | LiveKit docs | Pipeline nodes and hooks | LiveKit docs | Understanding Transcript Timing in Voice Conversations | Resemble AI TTS plugin guide | LiveKit Docs | Cartesia TTS plugin guide | LiveKit docs