can you update model prams using session.update_op...
# ask-ai
p
can you update model prams using session.update_options()
t
Thanks for reaching out, arpan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Absolutely, you can update model parameters using
session.update_options()
in LiveKit. The exact parameters you can change depend on the plugin you're working with: • Google Realtime API: You can update parameters like
voice
,
temperature
, and
tool_choice
. Just a heads-up, updating
instructions
might need a session restart. • OpenAI Realtime API: Parameters such as
voice
,
temperature
,
turn_detection
,
tool_choice
, and more can be updated smoothly without restarting the session. • Gladia STT: You have the flexibility to update a variety of parameters like
languages
,
translation_enabled
, and
custom_vocabulary
, which will affect all active streams. • Deepgram STT: Parameters including
language
,
model
,
interim_results
, and
keywords
can be updated for all active streams as well. If you'd like, I’m here to help with more details about any specific plugin or parameter—just let me know! Sources: livekit-agents/livekit/agents/voice/agent_activity.py
p
no i talike if middle of conversation user change language can i change language with session.update_options()
t
If you'd like to change the language in the middle of a conversation, the best way is to call
update_options(language=...)
directly on the STT (Speech-to-Text) and TTS (Text-to-Speech) components of your agent, instead of using
session.update_options()
. This helps ensure everything switches smoothly. Here’s a simple example to guide you:
Copy code
async def _switch_language(self, language_code: str):
    if self.tts is not None:
        self.tts.update_options(language=language_code)
    
    if self.stt is not None:
        self.stt.update_options(language=language_code)
    
    await self.session.say(f"Switched to {language_code}")
This way, both the transcription and voice output languages get updated dynamically. If you want to see this in action, there’s a helpful example in the Change Language recipe. And of course, if you’d like a hand implementing this or have any questions about a specific plugin, just reach out—I’m here to help! Sources: Hume TTS integration guide | LiveKit Docs | pipeline-tts/elevenlabs_change_language.py | livekit-plugins/livekit-plugins-google/livekit/plugins/google/stt.py | LiveKit Docs