Download edit\cutmap.py from Prompt48/PropmtEditor: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/Prompt48/PropmtEditor/resolve/b107bc59cd7e8d79a3e846735fc4de4d7a1626f2/edit%5Ccutmap.py
- Command line
-
hf download 'hf://Prompt48/PropmtEditor@b107bc59cd7e8d79a3e846735fc4de4d7a1626f2/edit\cutmap.py'
-
curl -L -o 'edit\cutmap.py' https://huggingface.co/Prompt48/PropmtEditor/resolve/b107bc59cd7e8d79a3e846735fc4de4d7a1626f2/edit%5Ccutmap.py
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)) | |