high-hairdresser-79251
02/26/2026, 5:14 AMtall-airline-16756
02/26/2026, 5:14 AMtall-airline-16756
02/26/2026, 5:14 AMhigh-hairdresser-79251
02/26/2026, 5:14 AMtall-airline-16756
02/26/2026, 5:15 AMsession.tts.update_options(
target_language_code="hi-IN",
speaker="shubh",
pace=1.2
)
You can update settings such as target_language_code, model, speaker, pace, and pitch mid-session. If you’d like, tell me which options you want to change and the SDK/platform you’re using (Python, JS, etc.), and I’ll provide a tailored code snippet.
Sources: Hume TTS plugin guide | LiveKit Documentationhigh-hairdresser-79251
02/26/2026, 5:16 AMtall-airline-16756
02/26/2026, 5:16 AMtarget_language mid-session with the Python SDK by calling update_options on your TTS session object. The new settings take effect on the next utterance.
Example Python snippet:
# Assuming `session` is your active Sarvam TTS session object
# and you previously initialized TTS (e.g., session.tts = ...)
# Update only the target language
session.tts.update_options(
target_language_code="hi-IN"
)
# After calling update_options, the next text you synthesize will use hi-IN
session.tts.speak("नमस्ते! यह नया लक्ष्य भाषा है।")
Notes and tips:
• update_options accepts the same parameters as the TTS constructor, so you can change other fields (e.g., speaker, pace, pitch, model) the same way.
• Changes apply on the next utterance — any currently-playing audio won’t be altered.
• If you run into an error when calling update_options, please share the exception text and a short copy of the code around your session/TTS initialization so I can help debug.high-hairdresser-79251
02/26/2026, 5:18 AMtall-airline-16756
02/26/2026, 5:18 AMupdate_options method is a LiveKit Agents feature, not something tied to a single TTS/STT provider. You can call update_options on agent TTS or STT objects to change parameters (language, voice/speaker, pace, pitch, model, etc.) during a session, and the changes take effect on the next utterance or transcription behavior.
If you want, I can:
• Show a short Python example that updates only target_language_code in your current session.
• Help verify your session code to ensure session.tts.update_options(...) is being called on the correct object and before the next speak() call.
Which would you prefer?
Sources: Build a multilingual voice agent that automatically switches languages | Li... | ElevenLabs Change Language | LiveKit Documentation | Gladia STT plugin guide | LiveKit Documentation | Hume TTS plugin guide | LiveKit Documentation | OpenAI TTS plugin guide | LiveKit Documentationhigh-hairdresser-79251
02/26/2026, 5:22 AMtall-airline-16756
02/26/2026, 5:22 AMstt_node or swapping the session’s stt instance). The switch can be triggered by a command, state change, or any other runtime condition, and will take effect for subsequent audio processing.
Below is a concise Python concept you can adapt. It shows toggling between Google and Sarvam STT when a flag changes (e.g., set by a user command). This is not a full runnable app but demonstrates the pattern to implement in your agent:
class MyAgent(Agent):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.use_sarvam = False
# initialize providers (or lazily create them)
self.google_stt = google.STT(api_key="...")
self.sarvam_stt = sarvam.STT(api_key="...")
async def stt_node(self, audio: AsyncIterable[rtc.AudioFrame], model_settings: ModelSettings):
# choose provider based on runtime flag
provider = self.sarvam_stt if self.use_sarvam else self.google_stt
# forward audio frames to the chosen provider and yield events
async for event in provider.stream(audio, model_settings):
yield event
async def handle_command(self, command_text: str):
# Example trigger: user says "switch to sarvam"
if "switch to sarvam" in command_text.lower():
self.use_sarvam = True
elif "switch to google" in command_text.lower():
self.use_sarvam = False
Key points and recommendations:
• The Agent architecture supports overriding pipeline nodes like stt_node so you can route audio dynamically.
• Ensure both provider plugins are installed (e.g., livekit-agents[google] and livekit-agents[sarvam]) and you have valid API keys.
• Switches take effect for subsequent audio; in-flight audio already being processed won’t be reprocessed.
• For lower latency, initialize providers ahead of time or use lazy initialization but keep the overhead in mind.
• If you want the switch triggered by an external signal (API call, UI button), expose a method or update shared state that your agent reads.
Would you like:
• A full, runnable example that listens for a voice command and switches providers automatically?
• A version that uses an external API call or websocket to trigger the switch instead of a voice command?
Tell me which option you prefer and any constraints (LiveKit agent version, how you want to trigger the switch, or if you want sample config for provider credentials), and I’ll provide the tailored sample.
Sources: Pipeline nodes and hooks | LiveKit Documentation | ElevenLabs Change Language | LiveKit Documentation | Sarvam STT plugin guide | LiveKit Documentation | Google Cloud STT plugin guide | LiveKit Documentationhigh-hairdresser-79251
02/26/2026, 5:27 AMtall-airline-16756
02/26/2026, 5:28 AMupdate_options on the Google STT instance (or update the session STT config) to change language_code — changes apply on the next processed audio.
• For TTS: switch which TTS instance the agent uses (e.g., set session.tts or flip a flag so the agent routes speak() calls to the Sarvam TTS). New utterances will use the Sarvam TTS.
• Trigger: detect the user request (voice command, text command, UI action) and perform both actions atomically so subsequent audio and TTS use Telugu + Sarvam.
Concise Python example (conceptual)
• This example shows: start with Google STT/TTS in English, listen for a "switch to Telugu" command, then update Google STT language and switch to Sarvam TTS. Adapt auth, imports, and integration points to your codebase.
# Conceptual example — adapt to your Agent framework and imports
class LangSwitchAgent(Agent):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Initialize providers (or lazily initialize)
self.google_stt = google.STT(api_key="GOOGLE_KEY", language_code="en-US")
self.google_tts = google.TTS(api_key="GOOGLE_KEY", language_code="en-US")
self.sarvam_tts = sarvam.TTS(api_key="SARVAM_KEY", target_language_code="te-IN")
# runtime routing state
self.current_tts = self.google_tts
self.current_stt = self.google_stt
async def stt_node(self, audio: AsyncIterable[rtc.AudioFrame], model_settings: ModelSettings):
# Route audio frames to the current STT provider
provider = self.current_stt
async for event in provider.stream(audio, model_settings):
# yield transcriptions/events into agent pipeline
yield event
async def speak(self, text: str):
# Use the current TTS provider for synthesizing speech
await self.current_tts.speak(text)
async def handle_transcript(self, transcript_text: str):
# Example: trigger phrase to switch to Telugu
if "switch to telugu" in transcript_text.lower() or "switch to telegu" in transcript_text.lower():
await self.switch_to_telugu()
# continue handling other transcript content...
async def switch_to_telugu(self):
# 1) Update Google STT language code so subsequent audio uses Telugu transcription
# Use update_options to change language; applies on next utterance
try:
self.google_stt.update_options(language_code="te-IN")
# swap current_stt to google_stt (still Google, but changed language)
self.current_stt = self.google_stt
except Exception as e:
# handle/log error — include exception text when asking for help
print("Failed to update Google STT options:", e)
raise
# 2) Switch TTS provider to Sarvam (set current_tts)
# Ensure Sarvam TTS is configured for Telugu
try:
# If Sarvam supports update_options too, ensure it's set to Telugu target language
self.sarvam_tts.update_options(target_language_code="te-IN")
self.current_tts = self.sarvam_tts
except Exception as e:
print("Failed to switch to Sarvam TTS:", e)
raise
# 3) Notify participants (optional)
await self.speak("తెలుగులో మేము మాట్లాడటం ప్రారంభిద్దాం.") # example Telugu utterance
# Hook up transcription events to handle_transcript, and TTS usage to speak() as appropriate
Key details and recommendations
• update_options: Use google_stt.update_options(language_code="te-IN"). The language change takes effect for the next processed audio (in-flight audio won’t be reprocessed).
• TTS switch: set which TTS instance you call for speak() (e.g., current_tts = sarvam_tts). You can also call sarvam_tts.update_options(target_language_code="te-IN") before the first Sarvam utterance.
• Provider initialization: initialize providers early or lazily to avoid perceptible latency when switching. Lazy initialization is fine but may add a small delay on the first use.
• Error handling: wrap update/swap calls and log exceptions. If switching fails, notify the user and keep a fallback (e.g., continue using Google TTS).
• Permissions/credentials: ensure both Google and Sarvam API keys are available to the agent.
• Edge cases: any audio already queued/being processed by the old STT won’t be re-transcribed; TTS already playing won’t change mid-playback. Plan UX (e.g., say “Switching to Telugu now” before switching).
Would you like:
• A full runnable sample (including Agent bootstrap, event wiring, and dependency list) that listens for the voice command and performs the switch?
• Or a version where the switch is triggered by an external API/UI call instead of a voice command?
Tell me which trigger you prefer and I’ll produce the tailored runnable example.high-hairdresser-79251
02/26/2026, 10:17 AMtall-airline-16756
02/26/2026, 10:17 AMupdate_options() and have the change take effect on the next utterance. Below is a concise Python approach tailored to your flow: start the agent with Google STT + Google TTS (English), then when the user requests Telugu, call update_options() on the Sarvam TTS (or set its options) and route subsequent speak() calls to Sarvam.
Key points
• update_options() is supported and accepts the same parameters as the constructor; changes apply to the next utterance.
• Switching the TTS provider is done by changing which TTS instance your agent calls for synthesis (e.g., current_tts = sarvam_tts).
• Initialize Sarvam (or lazy-init it) and call update_options(target_language_code="te-IN") before the first Sarvam speak() to ensure Telugu voice settings are applied.
• In-flight audio or audio already playing won’t be reprocessed or altered; the change affects subsequent utterances.
Concise Python pattern (conceptual)
class LangSwitchAgent(Agent):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# start with Google English
self.google_tts = google.TTS(api_key="GOOGLE_KEY", language_code="en-US")
# prepare Sarvam (can be lazy-initialized)
self.sarvam_tts = sarvam.TTS(api_key="SARVAM_KEY", target_language_code="en-US")
self.current_tts = self.google_tts
async def speak(self, text: str):
await self.current_tts.speak(text)
async def switch_to_sarvam_telugu(self):
# configure Sarvam for Telugu (takes effect on next speak)
self.sarvam_tts.update_options(target_language_code="te-IN")
# if you need to set voice/pitch/pace:
# self.sarvam_tts.update_options(speaker="...", pace=1.0, pitch=1.0)
# switch routing so future speak() uses Sarvam
self.current_tts = self.sarvam_tts
# optional: speak a confirmation in Telugu
await self.current_tts.speak("తెలుగులో మాట్లాడటం ప్రారంభిద్దాం.")
Recommended flow to trigger the switch
1. Detect the user request (voice transcript or UI command).
2. Call switch_to_sarvam_telugu() (or perform the two steps: sarvam_tts.update_options(...) then current_tts = sarvam_tts).
3. Subsequent speak() calls will use Sarvam with Telugu settings.
If you want, I can:
• Provide a full runnable example wired into your agent’s transcription events (voice command trigger).
• Show how to update Google STT language_code at the same time using google_stt.update_options(language_code="te-IN") so STT and TTS align.
Which would you prefer? Also tell me whether you want Sarvam lazy-initialized or pre-initialized so I can tailor the example.