Add corrected subtitles eval script (processing) F080 fix
Browse files
OSWorld-assets/multi_apps/9f3bb592-209d-43bc-bb47-d77d9df56504-subtitles-processing.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pysrt
|
| 2 |
+
import subprocess
|
| 3 |
+
|
| 4 |
+
AGENT_SRT = '/home/user/Documents/SubtitleProcessing/temp/processed_subtitles.srt'
|
| 5 |
+
GOLD_SRT = '/home/user/Documents/SubtitleProcessing/temp/processed_subtitles_Gold.srt'
|
| 6 |
+
VIDEO = '/home/user/Documents/SubtitleProcessing/temp/dialogue_training.mp4'
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def compare_srt_files(f1, f2):
|
| 10 |
+
try:
|
| 11 |
+
return pysrt.open(f1) == pysrt.open(f2)
|
| 12 |
+
except Exception:
|
| 13 |
+
return False
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def subtitles_removed_from_video(path):
|
| 17 |
+
try:
|
| 18 |
+
out = subprocess.run(["ffmpeg", "-i", path], capture_output=True, text=True).stderr
|
| 19 |
+
return "Subtitle" not in out
|
| 20 |
+
except Exception:
|
| 21 |
+
return False
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
if compare_srt_files(AGENT_SRT, GOLD_SRT) and subtitles_removed_from_video(VIDEO):
|
| 25 |
+
print("true")
|
| 26 |
+
else:
|
| 27 |
+
print("false")
|