Snap clip boundaries into detected silence to avoid mid-word cuts#132
Merged
Conversation
assembly clip now runs one ffmpeg silencedetect pass over the source and moves any clip boundary that lands mid-speech into the adjacent silence: a start backs into the previous silence (keeping the word it was chopping), an end runs forward into the next one, each settling SNAP_LEAD (0.25s) from the speech edge. Boundaries already in silence stay exactly where selected (so --padding is honored), boundaries with no silence within SNAP_REACH (1.5s) stay put, and a failed detection falls back to the selected times rather than failing the cut. --no-snap restores exact-time cuts. Also add the Steve Jobs commencement-speech clip example to the README. https://claude.ai/code/session_0196aTXN8jmNQwuwBDLTfmqU
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add automatic silence detection and boundary snapping to the
clipcommand so that clip cuts land in pauses rather than mid-word. When enabled (the default), ffmpeg'ssilencedetectfilter identifies silence intervals in the source media, and clip boundaries are moved into adjacent silence up to a configurable reach distance, keeping a small amount of silence next to the speech.Key Changes
Silence detection & parsing (
clip_select.py):parse_silences()extracts silence intervals from ffmpegsilencedetectfilter outputsilence_startandsilence_endlog linesBoundary snapping (
clip_select.py):snap_to_silences()moves clip boundaries into adjacent silence intervals_snap_start()and_snap_end()implement directional snapping logicSNAP_REACH = 1.5s) and lead (SNAP_LEAD = 0.25s) constantsIntegration (
clip_exec.py):_detect_silences()runs a dedicated ffmpeg pass withsilencedetectfiltersnapboolean option inClipOptions(default:True)CLI (
commands/clip.py):--snap/--no-snapflag (default: snap enabled)Tests:
parse_silences()covering normal cases, edge cases, and error handlingsnap_to_silences()tests covering reach bounds, narrow silences, overlapping segments, trailing silencerun_clip()workflowImplementation Details
-30dBthreshold with0.2sminimum duration (typical pause in speech)--paddingexactly)https://claude.ai/code/session_0196aTXN8jmNQwuwBDLTfmqU