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
)
| 224 | |
| 225 | |
| 226 | def 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 | |
| 257 | def process_transcripts_parallel( |