MCPcopy Create free account
hub / github.com/allenai/OLMoASR / calculate_transcript_length

Function calculate_transcript_length

scripts/data/processing/text_to_jsonl.py:71–90  ·  view source on GitHub ↗

Calculate the total length of a transcript in seconds. Args: transcript_start: Start times for transcript segments (format depends on TranscriptReader) transcript_end: End times for transcript segments (format depends on TranscriptReader) Returns: Total length

(transcript_start: Any, transcript_end: Any)

Source from the content-addressed store, hash-verified

69
70
71def calculate_transcript_length(transcript_start: Any, transcript_end: Any) -> float:
72 """
73 Calculate the total length of a transcript in seconds.
74
75 Args:
76 transcript_start: Start times for transcript segments (format depends on TranscriptReader)
77 transcript_end: End times for transcript segments (format depends on TranscriptReader)
78
79 Returns:
80 Total length in seconds, or 0 if calculation fails
81 """
82 if not transcript_start or not transcript_end:
83 return 0.0
84
85 try:
86 # Calculate difference returns time in milliseconds, convert to seconds
87 return calculate_difference(transcript_start, transcript_end) / 1000.0
88 except (ValueError, IndexError, TypeError) as e:
89 print(f"Warning: Failed to calculate transcript length: {e}")
90 return 0.0
91
92
93def process_transcript_file(

Callers 1

process_transcript_fileFunction · 0.85

Calls 1

calculate_differenceFunction · 0.90

Tested by

no test coverage detected