Spaces:
Running on Zero
Running on Zero
Download span_utils.py from Tom-Brenner/PhonePaint: direct link, hf CLI and curl.
- Browser
- Download file 627 Bytes
-
https://huggingface.co/spaces/Tom-Brenner/PhonePaint/resolve/main/span_utils.py
- Command line
-
hf download hf://spaces/Tom-Brenner/PhonePaint/span_utils.py
-
curl -L -o span_utils.py https://huggingface.co/spaces/Tom-Brenner/PhonePaint/resolve/main/span_utils.py
627 Bytes
| """Shared time-span helpers for PhonePaint inference.""" | |
| from __future__ import annotations | |
| from typing import List, Sequence, Tuple | |
| def apply_ext( | |
| spans: Sequence[Tuple[float, float]], | |
| *, | |
| ext_sec: float, | |
| max_end: float, | |
| ) -> List[Tuple[float, float]]: | |
| """Extend each span on both sides and clip it to the source duration.""" | |
| out: List[Tuple[float, float]] = [] | |
| for start, end in spans: | |
| clipped_start = max(0.0, start - ext_sec) | |
| clipped_end = min(max_end, end + ext_sec) | |
| if clipped_end > clipped_start: | |
| out.append((clipped_start, clipped_end)) | |
| return out | |