ancient-hospital-67205
12/24/2025, 3:01 PMtall-airline-16756
12/24/2025, 3:01 PMtall-airline-16756
12/24/2025, 3:02 PMeng) but the LiveKit turn detector only accepts two-letter codes (e.g., en). To fix it, force the STT language to the two-letter code in your configuration.
Example (Python):
from livekit.agents import AgentSession, inference
from livekit.plugins.turn_detector.multilingual import MultilingualModel
session = AgentSession(
stt=inference.STT(
model="elevenlabs/scribe_v2_realtime",
language="en" # use two-letter code
),
turn_detection=MultilingualModel(),
# ... other params
)
Try that and let me know if the error persists or which language you need so I can suggest the exact two-letter code.
Sources: Rime TTS | LiveKit docs | ElevenLabs STT | LiveKit docs | LiveKit turn detector plugin | LiveKit docsancient-hospital-67205
12/24/2025, 3:03 PMtall-airline-16756
12/24/2025, 3:03 PMeng.
Could you share:
• The AgentSession/STT config code you’re using (the exact snippet where you create inference.STT and AgentSession).
• A short sample of the transcription event or log that shows the language code (if available).
• Which LiveKit agent/plugin versions you’re running (package names/versions).
If you prefer, paste the minimal reproducible code that triggers the error and I’ll point out exactly where to map `eng`→`en` or adjust the config.
Sources: LiveKit turn detector plugin | LiveKit docs | ElevenLabs TTS plugin guide | LiveKit docs | ElevenLabs STT | LiveKit docsancient-hospital-67205
12/24/2025, 3:10 PMtall-airline-16756
12/24/2025, 3:11 PMlanguage_code = "en" but the logs show the ElevenLabs STT is still emitting "language": "eng". That confirms the turn detector is receiving eng and failing.
Two practical fixes — pick whichever fits your setup:
Option 1 — force the language at LiveKit Inference level (recommended if you use LiveKit agents)
• Use inference.STT and set language="en" so the agent supplies en to downstream plugins:
from livekit.agents import AgentSession, inference
from livekit.plugins.turn_detector.multilingual import MultilingualModel
stt = inference.STT(model="elevenlabs/scribe_v2_realtime", language="en")
session = AgentSession(
stt=stt,
turn_detection=MultilingualModel(),
# ...
)
Option 2 — map the three-letter code to two-letter code in your transcription handler (works if you must keep using elevenlabs.STT)
• Intercept transcription events and replace "eng" → "en" before passing to the turn detector:
def handle_transcript(event):
lang = event.get("language") or event.get("language_code")
if lang == "eng":
event["language"] = "en"
# pass event into turn detector / AgentSession pipeline
Why this is needed: ElevenLabs Scribe returns a 3-letter code (eng) while the turn detector only accepts 2-letter ISO codes (en).
If you want, paste the snippet where you forward STT results into the agent/turn detector and I’ll show the exact place to insert the mapping.ancient-hospital-67205
12/24/2025, 3:12 PMtall-airline-16756
12/24/2025, 3:12 PMhandle_transcript function where you receive/transmit STT events and before those events are handed to the turn detector or AgentSession pipeline. Two common approaches depending on how you integrate STT:
Option A — register a transcript callback on the session (preferred if your setup supports session events)
1. Define the handler near your session setup.
2. Register it as the transcript event handler so every transcription event is normalized before processing.
Example:
def handle_transcript(event):
lang = event.get("language") or event.get("language_code")
if lang == "eng":
event["language"] = "en"
# forward normalized event to session processing
session.process_transcript(event)
session = AgentSession(stt=stt, turn_detection=MultilingualModel(), ...)
session.on(event="transcript", handler=handle_transcript)
Option B — wrap/patch where you call the turn detector or feed transcripts into the agent If you manually call the turn detector or pass transcripts into the agent, call handle_transcript just before that call.
Example:
def handle_transcript(event):
if event.get("language") == "eng":
event["language"] = "en"
return event
# when you get a raw transcript:
normalized = handle_transcript(raw_event)
agent.handle_transcript(normalized) # or turn_detector.process(normalized)
If you share the portion of your code that currently forwards the ElevenLabs events into LiveKit (or the function you use to push transcripts into the agent), I’ll show the exact lines to insert the handler.