def create(cls, texts: List[Any], name: str, *, locations: Opt[List[float]] = None,
durations: Opt[List[float]] = None, default: bool = False) -> 'SubtitleTrack':
subtitles = []
if locations:
start_times, end_times = loc_util.start_end_locations_from_locations(locations)
elif durations:
start_times, end_times = loc_util.start_end_locations_from_intervals(durations)
else:
raise ex.ParameterError(f"Must provide either locations or durations for the subtitle track {name}")
for index, (text, start_time, end_time) in enumerate(zip(texts, start_times, end_times)):
subtitle = Subtitle(str(text), start_time, end_time)
subtitles.append(subtitle)
subtitle_track = cls(subtitles, name, default=default)
return subtitle_track
评论列表
文章目录