Spaces:
Running on Zero
Running on Zero
Restore probe
Browse files312 unmodified lines313314315316317318312 unmodified linesreturn Client(CONDITIONER_SPACE)def collect(image_paths, audio_path, video_path) -> list[tuple[str, str]]:"""The `(kind, path)` references of a request, **in the order the model reads them**.312 unmodified lines313314315316317318319320321322323324325326327328329330331332333312 unmodified linesreturn Client(CONDITIONER_SPACE)def probe(path: str) -> tuple[float | None, float | None]:"""`(video seconds, audio seconds)` of a media file, either being `None` when the stream is absent."""import avdef seconds(stream, container):if stream.duration is not None and stream.time_base is not None:return float(stream.duration * stream.time_base)return None if container.duration is None else container.duration / av.time_basewith av.open(path) as container:video = seconds(container.streams.video[0], container) if container.streams.video else Noneaudio = seconds(container.streams.audio[0], container) if container.streams.audio else Nonereturn video, audiodef collect(image_paths, audio_path, video_path) -> list[tuple[str, str]]:"""The `(kind, path)` references of a request, **in the order the model reads them**.
app.py+15