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

Function write_jsonl_output

scripts/data/processing/text_to_jsonl.py:226–254  ·  view source on GitHub ↗

Write transcript dictionaries to compressed JSONL file. Args: transcript_dicts: List of transcript metadata dictionaries output_path: Path for output JSONL file Raises: IOError: If writing to output file fails

(
    transcript_dicts: List[TranscriptDict], output_path: FilePath
)

Source from the content-addressed store, hash-verified

224
225
226def write_jsonl_output(
227 transcript_dicts: List[TranscriptDict], output_path: FilePath
228) -> None:
229 """
230 Write transcript dictionaries to compressed JSONL file.
231
232 Args:
233 transcript_dicts: List of transcript metadata dictionaries
234 output_path: Path for output JSONL file
235
236 Raises:
237 IOError: If writing to output file fails
238 """
239 # Create output directory if it doesn't exist
240 os.makedirs(os.path.dirname(output_path), exist_ok=True)
241
242 try:
243 print(f"Writing {len(transcript_dicts)} entries to {output_path}")
244
245 # Write to compressed JSONL file
246 with gzip.open(output_path, "wt", encoding="utf-8") as f:
247 for transcript_dict in transcript_dicts:
248 json_line = json.dumps(transcript_dict, ensure_ascii=False)
249 f.write(json_line + "\n")
250
251 print(f"Successfully wrote {len(transcript_dicts)} entries")
252
253 except Exception as e:
254 raise IOError(f"Failed to write output file {output_path}: {e}")
255
256
257def process_transcripts_parallel(

Callers 1

text_to_jsonlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected