When using custom pronounciarion, is it possible t...
# ask-ai
p
When using custom pronounciarion, is it possible to dump the term instead of the pronunciation to the transcript?
t
Thanks for reaching out, Mario. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking if a transcript can show the original term instead of the custom pronunciation. Yes — you can keep the spoken pronunciation for TTS while showing the original term in transcripts by post-processing the transcription output. Use the agent's
transcription_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 Docs
p
A P I -> API
t
Thanks — got it. Below is a ready-to-drop-in
transcription_node
example that replaces "A P I" with "API" before yielding transcripts, plus brief integration notes.
Copy code
# 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?
p
alright. What about mapping from text to speech?
t
You're asking how to map written text to a custom pronunciation for TTS (so transcripts stay the same while audio pronunciation changes). You can do this by transforming the text inside the agent's
tts_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):
Copy code
# 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:
Copy code
# 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 Docs
p
where is synthesize coming from and what does it do
t
Good question — in the examples I used
synthesize
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.
p
is replace case sensisive?
t
Yes — plain string
replace
calls are case-sensitive. How to make them case-insensitive: • JavaScript / TypeScript (regex with
i
flag):
Copy code
const replaced = text.replace(/api/gi, "API");
Use
g
to replace all occurrences and
i
for case-insensitive matching. • Python (
re
with
re.IGNORECASE
):
Copy code
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.
p
It looks like the transcription_node isn't being activated the first time the agent speaks...
t
Thanks — I’m responding to your note that
transcription_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 docs
p
I realize I'm using use_tts_aligned
t
Thanks — since you’re using
use_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