Skip to content

fix(openai): don't persist the per-call language passed to recognize() - #7820

Closed
Atharvsinh-codez wants to merge 1 commit into
livekit:mainfrom
Atharvsinh-codez:fix/openai-stt-recognize-language
Closed

Atharvsinh-codez wants to merge 1 commit into
livekit:mainfrom
Atharvsinh-codez:fix/openai-stt-recognize-language

Conversation

@Atharvsinh-codez

Copy link
Copy Markdown

Summary

openai.STT._recognize_impl wrote a per-call language back to self._opts, so one recognize(buffer, language="fr") changed the language for every later recognize() call and every new stream() on that STT.

This also hits the framework path. A non-streaming STT is wrapped in StreamAdapter, and StreamAdapter passes its stream's language to every recognize() call. Any STT built on the OpenAI plugin is affected, including groq.STT and the OpenAI-compatible providers. In that setup the STT stays on whatever language was requested last, and two streams with different languages overwrite each other's setting.

The override now goes on a copy of the options for that one request, which is how stream(language=...) already handles it. #6097 made the same fix for Clova.

s = openai.STT(model="whisper-1", language="en")
await s.recognize(buf, language="fr")  # sends fr
await s.recognize(buf)                 # before: sends fr, after: sends en

Test plan

  • added test_file_transcription_language_override_applies_to_one_call. It fails on main (the second request sends fr) and passes with this change.
  • uv run pytest tests/test_plugin_openai_stt_context.py tests/test_inference_stt_openai.py: 83 passed.
  • checked groq.STT the same way: the second request sends en, and _opts.languages stays ["en"].
  • ruff check, ruff format, and mypy (livekit.plugins.openai, livekit.plugins.groq) are clean.

STT._recognize_impl wrote a `language` override back to self._opts, so a
single recognize(language="fr") changed the language of every later
recognize() and new stream. StreamAdapter passes its stream's language on
every call, so a non-streaming OpenAI or Groq STT wrapped for a session
ended up pinned to whatever language was last requested.

Apply the override to a copy of the options for that request only, the
same way stream() already does.
@Atharvsinh-codez
Atharvsinh-codez requested a review from a team as a code owner October 14, 2026 15:12
@CLAassistant

CLAassistant commented Oct 14, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T15:14:57.220826Z 48a93cd PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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.

Devin Review

@Atharvsinh-codez

Copy link
Copy Markdown
Author

Folded into #7828 together with the other two STT fixes and a fix for the flaky unit-tests failure. Closing this one.

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.

2 participants