Skip to content

fix(voice): retain concrete language for turn detection#6531

Open
Oxygen56 wants to merge 1 commit into
livekit:mainfrom
Oxygen56:fix/turn-detector-ignore-multi-language
Open

fix(voice): retain concrete language for turn detection#6531
Oxygen56 wants to merge 1 commit into
livekit:mainfrom
Oxygen56:fix/turn-detector-ignore-multi-language

Conversation

@Oxygen56

Copy link
Copy Markdown

Fixes #6530

Summary

  • keep multi and auto language-detection modes from replacing the last concrete language
  • share the same language-tracking logic across final and preflight transcripts
  • add regression coverage for ambiguous multilingual results and later concrete-language updates

Root Cause

AudioRecognition stored every initial STT language value in _last_language. When a multilingual STT provider returned the mode value multi for an ambiguous utterance, the turn detector treated it as a concrete language code, could not find a matching threshold, and skipped end-of-turn prediction.

The STT event still retains the provider's original language value. Only the language tracked for language-specific turn-detection behavior ignores non-specific detection modes.

Verification

  • uv run --no-sync pytest tests/test_audio_recognition_turn_detection.py::TestLanguageTracking --audio_eot -q -> 3 passed
  • uv run --no-sync ruff check livekit-agents/livekit/agents/voice/audio_recognition.py tests/test_audio_recognition_turn_detection.py -> passed
  • uv run --no-sync ruff format --check livekit-agents/livekit/agents/voice/audio_recognition.py tests/test_audio_recognition_turn_detection.py -> passed
  • uv run --group typing mypy -p livekit.agents -> passed (205 source files)
  • uv run --no-sync pytest --unit -q -> 1142 passed, 4 skipped before the repository's concurrent-test runner stopped with 9 event-loop errors on Python 3.13

Notes for Reviewers

  • If no concrete language has been detected yet, multi leaves the tracked language unset and the existing endpointing fallback remains unchanged.
  • No public API or STT event payload is changed.

@Oxygen56
Oxygen56 requested a review from a team as a code owner July 23, 2026 21:42
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MutlilingualModel Turn Detector model does not support "multi" language code

2 participants