Hi I am using google’s realtime I wanna use only e...
# ask-ai
b
Hi I am using google’s realtime I wanna use only english language how to deal with it Can you please help
t
Thanks for reaching out, Madhav. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To restrict Google's Realtime API to only the English language in LiveKit, you can configure the
RealtimeModel
instance with the appropriate language parameter. Here’s how you can do it: 1. Initialization with Language: When creating a new instance of
RealtimeModel
, include the language parameter set to
"en-US"
.
Copy code
from livekit.plugins.google.beta.realtime import RealtimeModel

realtime_model = RealtimeModel(
    model="gemini-2.0-flash-live-001",
    language="en-US",
    api_key="your_api_key"
)
2. Dynamic Language Update: If you need to change the language after initialization, you can use the
update_options
method.
realtime_model.update_options(language="en-US")
These steps will ensure that the Google Realtime API processes only English language inputs.
b
but this is not working
t
Hey there! To get to the bottom of why the language restriction isn’t working, could you share a bit more info with me? • What’s the exact error message or the weird behavior you’re seeing? • Which language code are you trying to use (like "en-US")? • How are you setting up the
RealtimeModel
? If you can, a little code snippet would be super helpful! Once I have these details, I’ll be able to help you out better. Looking forward to your reply!
b
Copy code
GeminiRealtimeModel(
    model=self.config.llm_model,
    api_key=os.environ.get("GOOGLE_API_KEY"),
    voice=self.config.voice,
    temperature=self.config.temperature,
    language="en-US",
    realtime_input_config=RealtimeInputConfig(
        automatic_activity_detection=AutomaticActivityDetection(
            silence_duration_ms=self.config.turn_detection.silence_duration_ms,
        ),
    ),
)
t
Hey there! I see you've set the
language="en-US"
parameter in your
GeminiRealtimeModel
configuration to keep the output in English—nice job on that! Sometimes, though, things don’t work exactly as expected, and here are a few reasons why that might be happening: 1. Model-Specific Behavior: Some Gemini models might not always stick strictly to language restrictions. It’s a good idea to double-check that the model you’re using in
self.config.llm_model
actually supports the
en-US
language code. 2. API Response: Take a peek at the API response to make sure the language parameter is being applied properly. Looking at logs or debug info can really help clear this up. 3. Testing with Other Languages: Try swapping in a different language code, like
es-US
, just to see if anything changes. This can help figure out if the hiccup is with the
en-US
code itself or something broader in the setup. If you’re still running into trouble, it might be tied to the specific model or how the API is set up. Feel free to reach out if you want a hand going through these steps or if you need help troubleshooting further—I’m here for you! Sources: Gemini Live API integration guide | LiveKit Docs | livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime...