MCPcopy Create free account
hub / github.com/smacke/ffsubsync / make_reference_pipe

Function make_reference_pipe

ffsubsync/ffsubsync.py:303–400  ·  view source on GitHub ↗
(
    args: argparse.Namespace,
    progress_handler: Optional[Callable[[ProgressInfo], None]] = None,
)

Source from the content-addressed store, hash-verified

301
302
303def make_reference_pipe(
304 args: argparse.Namespace,
305 progress_handler: Optional[Callable[[ProgressInfo], None]] = None,
306) -> Pipeline:
307 pgs_stream = getattr(args, "pgs_ref_stream", None)
308 if pgs_stream is not None:
309 # "auto" (bare --pgs-ref-stream flag) → let PGSSpeechTransformer auto-detect
310 resolved_stream: Optional[str] = None if pgs_stream == "auto" else pgs_stream
311 if resolved_stream is not None and not resolved_stream.startswith("0:"):
312 resolved_stream = "0:" + resolved_stream
313 return Pipeline(
314 [
315 (
316 "speech_extract",
317 PGSSpeechTransformer(
318 sample_rate=SAMPLE_RATE,
319 start_seconds=args.start_seconds,
320 ffmpeg_path=args.ffmpeg_path,
321 ref_stream=resolved_stream,
322 gui_mode=args.gui_mode,
323 ),
324 ),
325 ]
326 )
327 ref_format = _ref_format(args.reference)
328 if ref_format in SUBTITLE_EXTENSIONS:
329 if args.vad is not None:
330 logger.warning("Vad specified, but reference was not a movie")
331 return cast(
332 Pipeline,
333 make_subtitle_speech_pipeline(
334 fmt=ref_format,
335 **override(args, encoding=args.reference_encoding or DEFAULT_ENCODING),
336 ),
337 )
338 elif ref_format in ("npy", "npz"):
339 if args.vad is not None:
340 logger.warning("Vad specified, but reference was not a movie")
341 return Pipeline(
342 [("deserialize", DeserializeSpeechTransformer(args.non_speech_label))]
343 )
344 else:
345 vad = args.vad or DEFAULT_VAD
346 if args.reference_encoding is not None:
347 logger.warning(
348 "Reference srt encoding specified, but reference was a video file"
349 )
350 ref_stream = args.reference_stream
351 if ref_stream is not None and not ref_stream.startswith("0:"):
352 ref_stream = "0:" + ref_stream
353 if getattr(args, "multi_segment_sync", False):
354 return Pipeline(
355 [
356 (
357 "speech_extract",
358 MultiSegmentVideoSpeechTransformer(
359 vad=vad,
360 sample_rate=SAMPLE_RATE,

Calls 8

PipelineClass · 0.90
_ref_formatFunction · 0.85
overrideFunction · 0.85