Spaces:
Sleeping
Sleeping
Claude commited on
Commit ·
d16cde4
1
Parent(s): 71844d0
Fix repeated audio in adjacent segments
Browse filesSentence stitching copies a cue (with its original timestamps) into
segment A while leaving a remainder cue with the same timestamps in
segment B. When audio bounds are snapped outward to whole cues, both
clips claimed the same time range and the overlapping audio played twice.
Fix: after computing all audio segments, clamp each clip's end to the
next clip's start so adjacent clips never overlap.
https://claude.ai/code/session_01EGBMur51izertyiu7msWPQ
app/pipeline/orchestrator.py
CHANGED
|
@@ -225,6 +225,15 @@ def run_pipeline(
|
|
| 225 |
audio_segments.append(
|
| 226 |
(i, min(f.start_seconds, cb[0]), max(f.end_seconds, cb[1]))
|
| 227 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
audio_paths = slice_segment_audio(
|
| 229 |
inputs.video_path,
|
| 230 |
audio_segments,
|
|
|
|
| 225 |
audio_segments.append(
|
| 226 |
(i, min(f.start_seconds, cb[0]), max(f.end_seconds, cb[1]))
|
| 227 |
)
|
| 228 |
+
# Clamp each clip's end to the next clip's start. Sentence stitching
|
| 229 |
+
# can assign the same cue (with identical timestamps) to two adjacent
|
| 230 |
+
# buckets, which causes the snapped-outward bounds to overlap and the
|
| 231 |
+
# overlapping audio to appear in both clips.
|
| 232 |
+
for j in range(len(audio_segments) - 1):
|
| 233 |
+
idx, start, end = audio_segments[j]
|
| 234 |
+
_, next_start, _ = audio_segments[j + 1]
|
| 235 |
+
if end > next_start:
|
| 236 |
+
audio_segments[j] = (idx, start, next_start)
|
| 237 |
audio_paths = slice_segment_audio(
|
| 238 |
inputs.video_path,
|
| 239 |
audio_segments,
|