Skip to content

fix: UnboundLocalError in transcribe when cloud + include_text=false#238

Open
javidjamae wants to merge 1 commit into
stephengpope:mainfrom
javidjamae:fix/transcribe-text-filename-unbound
Open

fix: UnboundLocalError in transcribe when cloud + include_text=false#238
javidjamae wants to merge 1 commit into
stephengpope:mainfrom
javidjamae:fix/transcribe-text-filename-unbound

Conversation

@javidjamae
Copy link
Copy Markdown

Summary

process_transcribe_media in services/v1/media/media_transcribe.py raises UnboundLocalError whenever a caller asks for cloud-mode output without text.

The else branch at line 137 assigns text_file = None (wrong name), but line 153 returns text_filename. In the common case of include_text=True the bug is hidden because the if branch assigns text_filename for real. The moment you disable include_text in cloud mode, Python bails out with:

cannot access local variable 'text_filename' where it is not associated with a value

Reproduction

POST /v1/media/transcribe
{
  "media_url": "https://.../speech.mp3",
  "response_type": "cloud",
  "include_text": false,
  "include_srt": true
}

The job is queued, Whisper transcribes, then the upload step explodes with the UnboundLocalError above and the job is marked failed.

Fix

One-line typo fix — bind text_filename = None in the else branch so the return statement sees a defined name.

             else:
-                text_file = None
+                text_filename = None

Test plan

  • Reproduced the error against upstream/main (d9bb567) using SRT-only cloud mode.
  • After the fix, the same request completes, the SRT is uploaded, and the webhook returns { srt_url, text_url: null, segments_url: null } as expected.
  • include_text=True path still behaves identically (the if branch was already correct).

🤖 Generated with Claude Code

When response_type is "cloud" and include_text is false, the else branch
assigned `text_file = None` but the function returns `text_filename` on
line 153, raising `UnboundLocalError: cannot access local variable
'text_filename' where it is not associated with a value`.

Reproducible via any call asking the toolkit for SRT-only cloud output:

  POST /v1/media/transcribe
  {
    "media_url": "https://.../audio.mp3",
    "response_type": "cloud",
    "include_text": false,
    "include_srt": true
  }

Fix: assign the correct variable name in the else branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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.

1 participant