gorgeous-hydrogen-44699
12/22/2025, 12:46 PMtall-airline-16756
12/22/2025, 12:46 PMtall-airline-16756
12/22/2025, 12:46 PMupdate_options() on the agent session's STT and TTS instances to change their language (or provider-specific language code) during a running session.
• After updating both, the agent can continue the same conversation and respond in the new language (commonly you’ll confirm the switch by greeting in the new language).
Implementation pattern (example)
# pseudocode example
self.session.tts.update_options(language="es") # TTS -> Spanish
self.session.stt.update_options(language="es-US") # STT -> provider-specific code
# continue the session; agent can greet in Spanish
Notes and options
• Some STT providers (e.g., Gladia) support code-switching and real-time translation; you can enable those features if you expect mixed-language input.
• Use provider-specific language codes when required (e.g., Deepgram vs. Gladia may differ).
Quick question to finish: Which STT/TTS providers and which target language(s) do you want to switch to? I can give exact code and language codes for your setup.
Sources: ElevenLabs Change Language | LiveKit docs | Gladia STT plugin guide | LiveKit docs | TTS Translator with Gladia STT | LiveKit docsgorgeous-hydrogen-44699
12/22/2025, 12:50 PMtall-airline-16756
12/22/2025, 12:51 PMAgentSession pattern and update_options() calls described earlier. Replace provider classes, language codes, and method names with those from your actual SDK if they differ.
# Example: switch STT and TTS language at runtime in an AgentSession
class MultilingualAgent:
def __init__(self, session):
# session should expose .tts and .stt instances and a send_message/handle flow
self.session = session
def handle_user_request(self, text_or_audio):
# normal handling (speech input -> transcribe -> respond)
transcript = self.session.stt.transcribe(text_or_audio)
response_text = self.generate_response(transcript)
self.session.tts.speak(response_text)
def switch_language(self, tts_language_code, stt_language_code):
"""
Change TTS and STT languages at runtime.
tts_language_code: provider-specific TTS language (e.g., "es" or "es-ES")
stt_language_code: provider-specific STT language (e.g., "es-US" or "es-ES")
"""
# update TTS
self.session.tts.update_options(language=tts_language_code)
# update STT
self.session.stt.update_options(language=stt_language_code)
# optional: confirm the switch vocally in the new language
confirmation = {
"es": "Idioma cambiado a español.",
"en": "Language switched to English.",
}.get(tts_language_code.split("-")[0], "Language switched.")
self.session.tts.speak(confirmation)
def generate_response(self, transcript):
# stub: implement your agent response generation
return f"You said: {transcript}"
Usage example:
# create session with provider-specific stt/tts instances
session = AgentSession(stt=DeepgramSTT(...), tts=ElevenLabsTTS(...))
agent = MultilingualAgent(session)
# normal flow
agent.handle_user_request(audio_input)
# on user request to switch languages (e.g., "Switch to Spanish")
agent.switch_language(tts_language_code="es-ES", stt_language_code="es-US")
# continue handling further input in Spanish
agent.handle_user_request(next_audio_input)
If you tell me which STT/TTS providers you use (e.g., Deepgram, Gladia, ElevenLabs) and the exact target language codes, I can give a provider-specific snippet with correct language codes and any provider-specific flags (e.g., code-switching or translation options).gorgeous-hydrogen-44699
12/22/2025, 12:54 PMtall-airline-16756
12/22/2025, 12:54 PMupdate_options() on the session's STT instance with the new language code.
• Continue the session; the STT will transcribe using the new language without needing to restart the session.
Minimal Python snippet
# assume session.stt exposes update_options(language=...)
# switch STT language at runtime
new_stt_language = "es-ES" # provider-specific code
session.stt.update_options(language=new_stt_language)
# continue handling audio; subsequent transcriptions use the new language
transcript = session.stt.transcribe(live_audio_chunk)
Would you like a provider-specific snippet (Deepgram, Gladia, etc.) or examples for handling mixed-language/code-switching?gorgeous-hydrogen-44699
12/22/2025, 12:55 PMtall-airline-16756
12/22/2025, 12:56 PMupdate_options() on the active stt instance. Below is a concise provider-agnostic Python example plus provider-specific notes.
Minimal async example
# Initialize session with an STT instance (must be an STT object, not a shorthand string)
session = AgentSession(
stt=inference.STT(model="deepgram/flux-general", language="en"),
tts=inference.TTS(...),
)
# Later, during the running session, update model and/or language
await session.stt.update_options(model="deepgram/flux-translate", language="es")
# Subsequent transcriptions use the new model/language
transcript = await session.stt.transcribe(audio_chunk)
Key notes
• The stt field must be an STT plugin or inference.STT instance; shorthand string configs (e.g., stt="deepgram/flux-general:en") do not support update_options.
• Supported providers include Deepgram, Gladia, Cartesia, fal, OpenAI, ElevenLabs, etc. Provider-specific language codes or model names may differ.
• For Deepgram you can use multi for multilingual input or specific codes like "es", "fr".
• Cartesia may require language suffixes (e.g., ":en"). Check the provider's code for exact model/language identifiers.
• If you expect mixed-language input, some providers (Gladia) support code-switching and translation flags (e.g., code_switching=True, translation_enabled=True).
If you tell me which STT provider and the exact model/language you want to switch to, I’ll give a provider-specific snippet with correct model names and language codes.
Sources: Speech-to-text (STT) models | LiveKit Docs | Cartesia STT | LiveKit docs | fal STT plugin guide | LiveKit docs | Gladia STT plugin guide | LiveKit docs | ElevenLabs STT | LiveKit docsgorgeous-hydrogen-44699
12/22/2025, 1:59 PMtall-airline-16756
12/22/2025, 1:59 PMstt instance doesn't have update_options. That usually means it was created as a shorthand/string descriptor or with an SDK/provider that doesn't expose the plugin API.
What I recommend
• If you want dynamic updates, initialize STT as a plugin object (not a string). Plugin-based STT instances expose update_options.
• Tell me which STT provider and how you currently create stt (paste the few lines of code). I’ll give an exact snippet to initialize the plugin and show how to call update_options to change model/language at runtime.
Quick example (Deepgram plugin vs shorthand)
• Shorthand (no update_options):
◦ stt="deepgram/nova-2:en" ← does not expose update_options
• Plugin (supports update_options):
◦ from livekit.plugins import deepgram
◦ stt = deepgram.STT(model="nova-2", language="en")
◦ await stt.update_options(model="nova-3", language="es")
Please paste your STT initialization code or name the provider and I'll provide the provider-specific code to enable dynamic model/language updates.
Sources: Deepgram STT plugin guide | LiveKit docs | ElevenLabs Change Language | LiveKit docs | Deepgram STT | LiveKit docs