creamy-tiger-14805
09/22/2025, 6:05 AMtall-airline-16756
09/22/2025, 6:05 AMtall-airline-16756
09/22/2025, 6:05 AMcreamy-tiger-14805
09/22/2025, 6:06 AMtall-airline-16756
09/22/2025, 6:07 AMupdate_options method. This means you can switch the transcription language on the fly without having to restart your session. If you'd like, I’m here to help you step-by-step with how to set this up for your specific needs—just let me know!
Sources: Gladia integration guide | LiveKit Docs | Gladia integration guide | LiveKit Docs | livekit-plugins/livekit-plugins-google/livekit/plugins/google/stt.pycreamy-tiger-14805
09/22/2025, 6:07 AMtall-airline-16756
09/22/2025, 6:08 AMupdate_options method:
# Example for Gladia STT plugin
from gladia import STT
gladia_stt = STT()
# Update the transcription language to Japanese and English
gladia_stt.update_options(languages=["ja", "en"])
This way, you’re setting the transcription language to Japanese and English. If you'd like, I’m here to help with an example for a specific STT plugin or any other questions you might have—just let me know!creamy-tiger-14805
09/22/2025, 6:28 AMtall-airline-16756
09/22/2025, 6:29 AMupdate_options method isn’t available on the base STT class. To fix this, you’ll want to use a specific STT plugin like Gladia, Deepgram, or Google, which includes this method. Here’s a friendly example using Gladia:
from livekit.plugins import gladia
# Instantiate the Gladia STT plugin
stt = gladia.STT()
# Update the transcription language dynamically
stt.update_options(languages=["ja", "en"])
Make sure you’re importing and using the right plugin for your setup. If you’d like, just let me know which STT provider you’re working with, and I’d be happy to help you further!
Sources: STT | LiveKit Agents | livekit-plugins/livekit-plugins-google/livekit/plugins/google/tts.py | Gladia integration guide | LiveKit Docscreamy-tiger-14805
09/22/2025, 6:31 AMtall-airline-16756
09/22/2025, 6:32 AMupdate_options within a tool call inside your agent! To get a clearer picture and offer the best guidance, could you share a bit more about how your agent is set up? For instance:
• Are you using a specific STT plugin like Gladia or Deepgram?
• How are you currently executing the tool call in your agent?
• Do you happen to have an example of your current implementation?
With these details, I’ll be able to provide a solution that fits your needs perfectly. Looking forward to your reply!creamy-tiger-14805
09/22/2025, 6:33 AMclass LivspaceInboundAgent(Agent):
def __init__(self,
chat_ctx=None,
user_project_details=None,
dial_info=dict[str, Any]):
self.__name__ = "livekit_livspace_inbound"
instructions = INSTRUCTIONS
super().__init__(
instructions=instructions,
# stt=elevenlabs.STT(),
stt=deepgram.STT(),
llm=google.LLM(model="gemini-2.5-flash-lite"),
tts=elevenlabs.TTS(
model="eleven_flash_v2_5",
voice_id="H8bdWZHK2OgZwTN7ponr",
voice_settings=elevenlabs.VoiceSettings(
stability=0.5,
similarity_boost=0.7,
speed=1.10,
),
streaming_latency=4
),
turn_detection=MultilingualModel(),
chat_ctx=chat_ctx,
)
self.dial_info = dial_info
self.user_project_details = user_project_details
self.participant: rtc.RemoteParticipant | None = None
@function_tool
async def language_detection(self, context: RunContext, language_code: str):
"""
Change the conversation language when the user expresses a language preference explicitly (Hindi/English)
Call this function when:
- Direct requests: "Can we speak in Hindi?", "Switch to Hindi", "Let's continue in Hindi"
- Questions about capability: "Do you speak Hindi?", "क्या आप हिंदी में बात करते हैं?"
- Stated preferences: "I would prefer Hindi", "Hindi would be better for me"
"""
<http://logger.info|logger.info>(f"Language detection function called with language: {language_code}")
# Map language codes to proper format for each service
language_mapping = {
"en": {"deepgram": "en-US", "elevenlabs": "en"},
"hi": {"deepgram": "hi", "elevenlabs": "hi"}
}
if language_code not in language_mapping:
logger.warning(f"Unsupported language code: {language_code}")
return f"Sorry, I don't support the language code '{language_code}'. I can only speak English (en) or Hindi (hi)."
# Update STT (Speech-to-Text) language
if self.stt is not None:
deepgram_lang = language_mapping[language_code]["deepgram"]
self.stt.update_options(language=deepgram_lang)
<http://logger.info|logger.info>(f"Updated STT language to: {deepgram_lang}")
# Update TTS (Text-to-Speech) language
if self.tts is not None:
elevenlabs_lang = language_mapping[language_code]["elevenlabs"]
self.tts.update_options(language=elevenlabs_lang)
<http://logger.info|logger.info>(f"Updated TTS language to: {elevenlabs_lang}")
return f"Language switched to {'Hindi' if language_code == 'hi' else 'English'}. I will now respond in this language."tall-airline-16756
09/22/2025, 6:34 AMupdate_options method call for your STT instance. Since you're using deepgram.STT(), it's a good idea to double-check that the update_options method is properly implemented and supports the language parameter.
Here’s a friendly checklist to help you verify and tweak your implementation:
1. Make sure the deepgram.STT plugin is correctly imported and initialized.
2. Check that the update_options method in deepgram.STT actually supports the language parameter. If it doesn’t, the plugin documentation might have the right method or parameter name you need.
3. Try testing the update_options method on its own to see if it updates the language as expected:
from livekit.plugins import deepgram
stt = deepgram.STT()
stt.update_options(language="en-US")
If this standalone test works but you still face issues when calling it within your tool, there could be something up with how the self.stt instance is being handled or passed around in your agent. Please feel free to reach out if you want me to walk you through it or if you need any more help—I’m here for you!creamy-tiger-14805
09/24/2025, 11:04 AMtall-airline-16756
09/24/2025, 11:04 AMupdate_options method. This means that configuration options, like the language, need to be set when you first initialize the plugin and can’t be changed on the fly. If you’re looking for dynamic language switching, I’d recommend trying a plugin like Deepgram, which does support update_options. I hope this helps, and please feel free to ask if you have any more questions!
Sources: livekit-plugins/livekit-plugins-azure/livekit/plugins/azure/stt.py | STT | LiveKit Agentscreamy-tiger-14805
09/24/2025, 11:05 AMtall-airline-16756
09/24/2025, 11:06 AMcreamy-tiger-14805
09/24/2025, 11:08 AMtall-airline-16756
09/24/2025, 11:09 AMcreamy-tiger-14805
09/24/2025, 12:32 PMtall-airline-16756
09/24/2025, 12:33 PMupdate_options method for the TTS plugin was called correctly and that the language parameter was indeed updated to Hindi?
• It’s also possible that the text being sent to the TTS engine is still in English. It would be great to verify if the input text is being translated or generated in Hindi before it reaches the TTS engine.
• Another thing to consider is whether the TTS plugin fully supports Hindi or if it needs some extra configuration to produce the correct language output.
Please feel free to share more details about your setup or let me know if you’d like me to help you troubleshoot any of these steps. I’m here to assist you!creamy-tiger-14805
09/24/2025, 12:34 PMtall-airline-16756
09/24/2025, 12:35 PMbefore_tts_cb callback: This is a handy way to check or tweak the text right before it goes to the TTS engine. For instance, you might add a translation service here to ensure the text is perfectly in Hindi.
3. Configure the TTS plugin: Don’t forget to set the target_language_code parameter to Hindi (like hi-IN) so the TTS engine speaks in Hindi as expected.
If you'd like, I’m here to help you step-by-step with these or assist in setting up a translation service. Just let me know!
Sources: Sarvam TTS integration guide | LiveKit Docs | Sarvam TTS integration guide | LiveKit Docs | Agents 0.x migration guide | LiveKit Docs | VoicePipelineAgent | LiveKit Docs | Pipeline nodes and hooks | LiveKit Docscreamy-tiger-14805
09/24/2025, 12:41 PMbefore_tts_cb callback
explain thistall-airline-16756
09/24/2025, 12:42 PMbefore_tts_cb callback in LiveKit is a wonderful tool that lets you tweak or check the text generated by the LLM before it reaches the TTS engine. This can be really helpful to make sure the text is in the right language, tidy up the formatting, or make any other adjustments you might need.
Here’s a friendly example to show you how it works:
def before_tts_callback(agent, text: str):
# Example: Ensure the text is in Hindi (you can integrate a translation service here)
if not is_hindi(text):
text = translate_to_hindi(text) # Custom function to translate text to Hindi
return text
agent = VoicePipelineAgent(
# Other configurations...
before_tts_cb=before_tts_callback,
)
In this example, the callback kindly checks if the text is in Hindi and translates it if needed. If you’d like, I’m here to help you set this up or assist with integrating a translation service—just let me know!
Sources: chain-of-thought-tts/agent.py | VoicePipelineAgent | LiveKit Docs | VoicePipelineAgent | LiveKit Docscreamy-tiger-14805
09/24/2025, 12:46 PMtall-airline-16756
09/24/2025, 12:46 PMbefore_tts_cb function by adding some conditional logic right inside the callback. For instance, you might want to check certain things like the language or the context, and then tweak the text only when it makes sense:
def before_tts_callback(agent, text: str):
# Example: Only modify text if the language is not Hindi
if agent.current_language != "hi":
text = translate_to_hindi(text) # Custom function to translate text to Hindi
return text
agent = VoicePipelineAgent(
# Other configurations...
before_tts_cb=before_tts_callback,
)
Here, the callback looks at the agent's current language and only applies the translation if it’s not Hindi. You can easily adjust this logic to fit exactly what you need. If you have any questions or want to explore this further, just let me know—I’m here to help!creamy-tiger-14805
09/24/2025, 1:39 PMtall-airline-16756
09/24/2025, 1:40 PMpip install "livekit-agents[google]~=1.2" to add the Google STT plugin to your setup.
2. Set up authentication: You’ll need to provide your Google Cloud credentials. Here are a few ways you can do this:Also, make sure the Cloud Speech-to-Text API is enabled in your Google Cloud project.
◦ Pass the credentials through the credentials_info dictionary.
◦ Set the path to your JSON key file using the credentials_file parameter or the GOOGLE_APPLICATION_CREDENTIALS environment variable.
◦ Or simply use Application Default Credentials (ADC).
1. Initialize the STT instance:
from livekit.plugins import google
stt_instance = google.STT(
model="chirp", # Use the advanced 'chirp' model
spoken_punctuation=False, # Disable spoken punctuation
languages="en-US", # Specify language
interim_results=True # Enable interim (partial) results
)
Integrate with your agent: You can now use the STT instance within an AgentSession like this:
session = AgentSession(
stt=stt_instance,
# ... other components like LLM, TTS, etc.
)
If you have any questions or need a hand with the setup, please don’t hesitate to reach out—I’m here to help!
Sources: Google Cloud STT integration guide | LiveKit Docs | livekit-plugins/livekit-plugins-assemblyai/livekit/plugins/assemblyai/stt.p... | Google integration guide | LiveKit Docs | Google integration guide | LiveKit Docs | Google Cloud STT integration guide | LiveKit Docs