Skip to content

Fix repeated text matching in audio and video clips#177

Merged
LauraGPT merged 2 commits into
mainfrom
codex/fix-duplicate-text-match
Jul 16, 2026
Merged

Fix repeated text matching in audio and video clips#177
LauraGPT merged 2 commits into
mainfrom
codex/fix-duplicate-text-match

Conversation

@LauraGPT

@LauraGPT LauraGPT commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • initialize bracket-match state for every requested text segment in both audio and video clipping
  • preserve the existing behavior of returning all repeated text matches when no offsets are supplied
  • prevent a previous # segment's bracket match from leaking into the next segment
  • format and surface offset warnings from both clipping entry points
  • keep explicit timestamp_list clipping independent of text-match warning state
  • add regressions for all affected audio and video paths

Problem

When an unbracketed query occurs more than once, proc() correctly returns multiple timestamp ranges. Both clipping paths then evaluate match in if len(ts) > 1 and match, but match was only assigned inside the bracket branch. This raises:

UnboundLocalError: cannot access local variable 'match' where it is not associated with a value

This is the repeated-text failure reproduced while answering Discussion #128.

Validation

  • regression baseline on current main: 2 tests failed with the exact UnboundLocalError
  • focused regression suite: 5/5 passed
  • full repository unittest discovery: 19 passed, 1 optional live test skipped
  • Ruff on the new test and targeted syntax/undefined-name rules on both changed files
  • py_compile, formatter check, and git diff --check
  • real MoviePy/FFmpeg smoke with a 4-second H.264/AAC input:
    • repeated query matched 0.5-1.0s and 2.5-3.0s
    • output duration: exactly 1.000s
    • output codecs: H.264 video + AAC audio
    • clipped SRT contains two consecutive 0.5-second 重复 entries
    • repeated offset query returned the formatted No.1 ... 2 periods warning in the final video message

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request initializes the match variable to None in the text-splitting loops of both clip and video_clip methods in funclip/videoclipper.py to prevent stale matches, and adds a new test suite to verify duplicate text matching. The review feedback identifies two issues in these loops: in clip, the log_append string contains unformatted placeholders, and in video_clip, log_append is constructed but never appended to the final message, causing warning logs to be lost.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread funclip/videoclipper.py Outdated
Comment thread funclip/videoclipper.py Outdated
@LauraGPT
LauraGPT merged commit d30dacc into main Jul 16, 2026
@LauraGPT
LauraGPT deleted the codex/fix-duplicate-text-match branch July 16, 2026 13:16
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