Download backend/src/clip_duration.py from new-arc/vector: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/new-arc/vector/resolve/main/backend/src/clip_duration.py
- Command line
-
hf download hf://spaces/new-arc/vector/backend/src/clip_duration.py
-
curl -L -o clip_duration.py https://huggingface.co/spaces/new-arc/vector/resolve/main/backend/src/clip_duration.py
1.06 kB
| """Task-specific clip length presets shared by selection and rendering.""" | |
| from dataclasses import dataclass | |
| from typing import Any | |
| class ClipDuration: | |
| minimum: int | |
| maximum: int | |
| ideal_minimum: int | |
| ideal_maximum: int | |
| CLIP_DURATIONS = { | |
| "auto": ClipDuration(15, 60, 25, 50), | |
| # Ideal maxima leave room for the sentence rewind/extension before the cap. | |
| "short": ClipDuration(15, 30, 18, 25), | |
| "medium": ClipDuration(30, 60, 35, 55), | |
| "long": ClipDuration(60, 120, 75, 110), | |
| } | |
| def validate_clip_length(value: Any) -> str: | |
| if not isinstance(value, str) or value not in CLIP_DURATIONS: | |
| raise ValueError("clip_length must be auto, short, medium, or long") | |
| return value | |
| def normalize_clip_length(value: Any) -> str: | |
| """Stored task settings fall back to Auto instead of failing the job.""" | |
| return value if isinstance(value, str) and value in CLIP_DURATIONS else "auto" | |
| def clip_duration(value: str = "auto") -> ClipDuration: | |
| return CLIP_DURATIONS[validate_clip_length(value)] | |