A Python check for voice-over overlap in AI video recaps

A Python check for voice-over overlap in AI video recaps

A first automatic cut can keep the right frame and cover the line that makes it work. Consider a fictional basketball game. A team comes back to tie the score. The narrator calls the basket while a player shouts “Get back on defense!” The question is whether the overlap was intentional.

第一次自动剪辑可以保留正确的画面,并覆盖掉使其生效的台词。设想一场虚构的篮球比赛。一支球队追平了比分。解说员在播报进球时,一名球员大喊:“回防!”问题在于这种重叠是否是有意的。

For clips with separate source and narration tracks, flag overlaps between time ranges the editor marked as important and the scheduled narration. Use timestamps relative to the same edit timeline. An original source timecode is not an edit timecode.

对于具有独立源轨道和解说轨道的剪辑,请标记编辑者标记为重要的时间范围与预定解说之间的重叠部分。请使用相对于同一编辑时间轴的时间戳。原始素材的时间码并非编辑时间码。

from itertools import pairwise

def covered_seconds(mark, narration):
    start, end = mark
    cuts = sorted({start, end} | {
        point for left, right in narration 
        for point in (left, right) 
        if start < point < end 
    })
    return sum(
        b - a for a, b in pairwise(cuts) 
        if any(left < b and a < right for left, right in narration)
    )

court_call = (8.0, 9.2)
cut_a = [(6.1, 10.4)]
cut_b = [(6.1, 7.9), (9.3, 10.4)]

for label, spans in (("A", cut_a), ("B", cut_b)):
    print(f"{label}: {covered_seconds(court_call, spans):.2f}s")

On Python 3.10 or later, this prints A: 1.20s and B: 0.00s for the synthetic timing above. Using the union of intervals avoids counting a span twice when two narration clips overlap each other.

在 Python 3.10 或更高版本中,上述合成时间设置的输出结果为 A: 1.20s 和 B: 0.00s。使用区间的并集可以避免在两个解说片段重叠时重复计算同一跨度。

A timing check only identifies where to listen. It cannot tell if the shout is audible in the rendered mix. Compare both edits with the picture unchanged and play each export from one line before the basket. Ask a viewer what made them expect the next possession. If the shout stays, time the caption to the actual line. The basketball scenario and timecodes are fictional. AI generated this draft and the teaching diagram.

时间检查只能确定需要监听的位置。它无法判断在渲染后的混音中是否能听到喊叫声。在画面不变的情况下比较两种剪辑,并从进球前的一行台词开始播放每个导出文件。询问观众是什么让他们预料到下一次球权。如果保留了喊叫声,请将字幕与实际台词对齐。文中的篮球场景和时间码均为虚构。本草稿及教学图示由人工智能生成。