PropmtEditor / edit\cutmap.py
Prompt48's picture
Upload edit\cutmap.py with huggingface_hub
d81ecd8 verified
Raw
History Blame
1.28 kB
"""Shared cut map: source intervals removed, and source->output time mapping."""
# (start, end) in SOURCE seconds to REMOVE (dead-air / loading / thinking pauses)
REMOVED = [
(268.92, 269.70), # "fire this up." pause
(271.58, 273.16), # model "thinking" dead-air (keep a beat, drop the rest)
(315.70, 316.60), # loading pause before "20 tokens per second"
]
SRC_DURATION = 393.79
def keep_segments():
"""Complement of REMOVED over [0, SRC_DURATION]."""
segs = []
cur = 0.0
for a, b in REMOVED:
if a > cur:
segs.append((cur, a))
cur = b
if cur < SRC_DURATION:
segs.append((cur, SRC_DURATION))
return segs
def map_time(t: float) -> float:
"""Map a SOURCE timestamp to the OUTPUT (post-cut) timeline."""
removed_before = 0.0
for a, b in REMOVED:
if t >= b:
removed_before += (b - a)
elif t > a: # inside a removed gap -> clamp to gap start
return a - removed_before
return t - removed_before
def out_duration() -> float:
return map_time(SRC_DURATION)
if __name__ == "__main__":
print("keep segments:", [(round(a, 2), round(b, 2)) for a, b in keep_segments()])
print("output duration:", round(out_duration(), 2))