I am using gemini realtime plugin for audio-audio ...
# ask-ai
p
I am using gemini realtime plugin for audio-audio conversation but one major issue I am having is the transcription of the user input. sometimes, the transcription picks a random, unrelated language, which is extremely annoying and ruins the conversation experience instantly. how would you recommend bypassing this?
t
Thanks for reaching out, adit-kulkarni. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I hear your frustration. You can stop Gemini from randomly switching transcription languages by explicitly disabling auto-detection and forcing the transcription language, or by handling STT outside Gemini. Two practical options: 1) Force a transcription language in the Gemini realtime plugin (recommended) • Enable
input_audio_transcription
and set
language
to the desired BCP-47 code (for example
"en"
for English). This prevents automatic language detection and keeps transcriptions in that language. • Example pattern:
Copy code
session = AgentSession(
  llm=google.realtime.RealtimeModel(
    model="gemini-2.5-flash",
    input_audio_transcription=google.types.InputTextTranscription(
      enabled=True,
      language="en"
    ),
  ),
)
2) Use a separate, deterministic STT pipeline and feed text to Gemini • Send audio to a dedicated STT provider you control (Google Cloud STT, Deepgram, etc.) with a fixed language setting. • Provide the resulting text to Gemini in text-only mode for response generation while still using Gemini for speech output if needed. • This gives more reliable language control and lets you handle retries/quality checks before sending text to Gemini. Which would you prefer to try first — forcing the plugin language or using an external STT? If you want, tell me the language code you need and the SDK/language you’re using and I’ll give exact code snippets. Sources: Gemini Live API plugin | LiveKit docs | Realtime model plugins | LiveKit Docs
p
i am using model="gemini-2.5-flash-native-audio-preview-09-2025" for this can i change the input audio transcription?
t
Thanks — I’m responding to your question about whether you can change the input audio transcription language for model "gemini-2.5-flash-native-audio-preview-09-2025". Short answer: No — that model uses automatic language detection and does not expose a setting to force or override the input transcription language. What you can do instead: • Use clear instructions (e.g., “Respond only in English”) to bias the model’s outputs. • Improve audio quality (noise reduction, single-speaker input) to help detection. • Use an external STT with a fixed language (Google Cloud STT, Deepgram, etc.), then send the text into Gemini (text-only) or a separate TTS step — this gives deterministic language control. Which option would you like to try? If you pick external STT, tell me your tech stack and target language and I’ll provide exact integration steps. Sources: Gemini Live API plugin | LiveKit docs
p
well the model actually understands me in the target language so its not an issue of the model understanding, its just an issue with the transcription
t
Thanks — I see you’re saying the model understands the target language but the transcription output sometimes switches languages. I hear the frustration; that mismatch between understanding and transcription is disruptive. Quick summary: you cannot force the transcription language for model "gemini-2.5-flash-native-audio-preview-09-2025" — it uses automatic detection and doesn’t expose a language override. Given that, here are practical options you can use right now: • Use instructions to bias behavior: include a prompt like “Transcribe and respond only in English” (or your target language) to reduce erroneous outputs. • Improve audio quality: ensure single-speaker input, reduce background noise, and use a good microphone — clearer audio improves automatic detection accuracy. • External STT (recommended if you need deterministic control): send audio to a dedicated STT provider with a fixed language setting (Google Cloud STT, Deepgram, DeepSpeech, etc.), then pass the resulting text to Gemini (text-only) or to your pipeline for TTS. This gives you reliable, language-fixed transcripts while still using Gemini for responses/speech. Which target language do you need, and what SDK / tech stack are you using (browser, Node, Python, Mobile)? Tell me that and I’ll give a precise integration example or prompt template.
p
eg for spanish what i would like is for the audio to be passed to the realtime model but also to, in parallel, be passed to a separate speech to text provider, is this possible?
t
Yes — you can send audio to the Gemini realtime model and, in parallel, to a separate STT provider for reliable Spanish transcripts. Two practical approaches: 1) Use LiveKit Agents' built-in STT plugin alongside the realtime model (recommended) • Configure
llm=google.realtime.RealtimeModel(...)
and set
stt=assemblyai.STT(language_code="es")
(or
google.STT(..., language_code="es-ES")
) in the same AgentSession. • Disable Gemini’s automatic activity detection if you want STT-based turn detection. • This streams the same audio to Gemini for realtime audio processing and to the external STT for deterministic Spanish transcription (captions, logging, or turn detection). 2) Manual audio forking (advanced) • Duplicate the audio frames client- or server-side. • Send one stream to Gemini Live API and the other to your chosen STT (Deepgram, AssemblyAI, Google STT). • This gives full control over buffering, retries, and post-processing. If you tell me your tech stack (Python or Node), whether you need captions or backend logging, and which STT provider you prefer, I’ll provide exact configuration or code snippets for Spanish. Sources: Gemini Live API plugin | LiveKit docs | Google AI and LiveKit | LiveKit Docs | Speech-to-text (STT) models | LiveKit Docs
p
i got a couple of successes with my tool but then it ran into this issue: ERROR livekit.…ns.google error in receive task: received 1011 (internal error) Internal error occurred.; then sent 1011 (internal error) Internal error occurred. Traceback (most recent call last): File "/Users/aditkulkarni/Sarovia/livekit-agent/.venv/lib/python3.10/site-packages/livekit/plugins/google/realtime/realtime_api.py", line 810, in _recv_task async for response in session.receive(): File "/Users/aditkulkarni/Sarovia/livekit-agent/.venv/lib/python3.10/site-packages/google/genai/live.py", line 453, in receive while result := await self._receive(): File "/Users/aditkulkarni/Sarovia/livekit-agent/.venv/lib/python3.10/site-packages/google/genai/live.py", line 534, in _receive raw_response = await self._ws.recv(decode=False) File "/Users/aditkulkarni/Sarovia/livekit-agent/.venv/lib/python3.10/site-packages/websockets/asyncio/connection.py", line 322, in recv raise self.protocol.close_exc from self.recv_exc websockets.exceptions.ConnectionClosedError: received 1011 (internal error) Internal error occurred.; then sent 1011 (internal error) Internal error occurred. {"room": "saraspeak-personalized_roleplay-810ec07c", "agent": "saraspeak-tutor", "pid": 61949, "job_id": "AJ_PVZugbm3wjo2", "room_id": "RM_pGMZfy5RZFwM"} Traceback (most recent call last): File "/Users/aditkulkarni/Sarovia/livekit-agent/.venv/lib/python3.10/site-packages/livekit/plugins/google/realtime/realtime_api.py", line 810, in _recv_task async for response in session.receive(): File "/Users/aditkulkarni/Sarovia/livekit-agent/.venv/lib/python3.10/site-packages/google/genai/live.py", line 453, in receive while result := await self._receive(): File "/Users/aditkulkarni/Sarovia/livekit-agent/.venv/lib/python3.10/site-packages/google/genai/live.py", line 534, in _receive raw_response = await self._ws.recv(decode=False) File "/Users/aditkulkarni/Sarovia/livekit-agent/.venv/lib/python3.10/site-packages/websockets/asyncio/connection.py", line 322, in recv raise self.protocol.close_exc from self.recv_exc websockets.exceptions.ConnectionClosedError: received 1011 (internal error) Internal error occurred.; then sent 1011 (internal error) Internal error occurred.
t
Thanks — I’m sorry that 1011 errors interrupted your runs. I’m responding to your traceback and will help you narrow the cause and add resilience. Quick checklist and next steps to try now (start in this order): 1) Retry with exponential backoff • Wrap the realtime session / receive loop in a retry with exponential backoff and jitter. 1011 is usually a transient server-side failure; retries resolve many occurrences. 2) Add robust receive error handling • Catch
websockets.exceptions.ConnectionClosedError
in your receive loop, log
e.code
and full traceback, close/cleanup the session, wait, then recreate the session and resume. 3) Log contextual metadata when it happens • Room ID, agent/job ID, timestamps, model name (
gemini-2.5-flash-native-audio-preview-09-2025
), region/project, and recent request rate. Include a short audio sample filename or size if reproducible. 4) Check quotas, billing, and API health • Confirm billing is active and check Google Cloud/Generative AI quotas for your project and the Google Cloud status dashboard for any incidents at the time of failures. 5) Validate audio and config • Ensure audio frames match expected sample rate/format and you’re not sending malformed frames mid-stream. If you fork audio to STT in parallel, confirm no stream corruption occurs. • If you disabled automatic activity detection or changed VAD, try toggling that to see if behavior changes. 6) Upgrade dependencies • Make sure you’re on the latest
livekit-agents
and
google-genai
packages — connection resilience fixes are regularly released. 7) Minimal repro test • Run a minimal script that only creates a realtime session, streams a short clean audio clip, and receives responses. If the minimal test fails, the issue is likely server-side or quota-related. If you want, I can give a short example of: • A Python retry wrapper around the receive loop, or • A minimal repro script to isolate client vs. server issues. Which would help you most right now — the retry code snippet or the minimal repro script? Also tell me whether you’re running this locally or in a cloud environment and whether failures correlate with traffic spikes.