Evaluate a text file using the provided model. Args: model: The model to use for evaluation. transcript_path (str): Path to the transcript file (.srt or .txt). retry_limit (int): Number of retry attempts for evaluation. Returns: Dict or None: Evaluation
(model, transcript_path, retry_limit)
| 59 | |
| 60 | |
| 61 | def evaluate_text_file(model, transcript_path, retry_limit): |
| 62 | """ |
| 63 | Evaluate a text file using the provided model. |
| 64 | |
| 65 | Args: |
| 66 | model: The model to use for evaluation. |
| 67 | transcript_path (str): Path to the transcript file (.srt or .txt). |
| 68 | retry_limit (int): Number of retry attempts for evaluation. |
| 69 | |
| 70 | Returns: |
| 71 | Dict or None: Evaluation results if successful, None if file format unsupported. |
| 72 | """ |
| 73 | if not transcript_path.endswith(('.srt', '.txt')): |
| 74 | print(f"Skipping {transcript_path}: Unsupported file format for text evaluation.") |
| 75 | return None |
| 76 | |
| 77 | if transcript_path.endswith(".srt"): |
| 78 | transcript = parse_srt_to_text(transcript_path) |
| 79 | elif transcript_path.endswith(".txt"): |
| 80 | with open(transcript_path) as f: |
| 81 | transcript = f.read().strip() |
| 82 | else: |
| 83 | raise ValueError("Unrecognized transcript file format.") |
| 84 | |
| 85 | capital_letter_proportion = sum(1 for c in transcript if c.isupper()) / sum(1 for c in transcript if c.isalpha()) |
| 86 | if capital_letter_proportion < 0.01: |
| 87 | transcript = fix_transcript(model, transcript) |
| 88 | |
| 89 | print(f"Performing text evaluation: {os.path.basename(transcript_path)}") |
| 90 | result = evaluate_text(model, transcript, retry_limit) |
| 91 | return result |
| 92 | |
| 93 | |
| 94 | def evaluate_video_file(model, video_path, transcript_path, description_path, target_fps=None, output_folder=None): |
no test coverage detected