Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -107,24 +107,30 @@ def process_video(video_file, language="hindi", progress=gr.Progress()):
|
|
| 107 |
print(f"Creating SRT at: {srt_path}")
|
| 108 |
print(f"Total chunks to process: {len(transcription_result['chunks'])}")
|
| 109 |
|
| 110 |
-
# Use
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
f.write(f"{i}\n")
|
| 119 |
f.write(f"{format_srt_time(start)} --> {format_srt_time(end)}\n")
|
| 120 |
f.write(f"{text}\n\n")
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
# Verify SRT was created and show preview
|
| 130 |
if not os.path.exists(srt_path):
|
|
|
|
| 107 |
print(f"Creating SRT at: {srt_path}")
|
| 108 |
print(f"Total chunks to process: {len(transcription_result['chunks'])}")
|
| 109 |
|
| 110 |
+
# Use EXACT approach from your working code - NO modifications
|
| 111 |
+
try:
|
| 112 |
+
with open(srt_path, 'w', encoding='utf-8-sig') as f:
|
| 113 |
+
if 'chunks' in transcription_result:
|
| 114 |
+
for i, chunk in enumerate(transcription_result['chunks'], start=1):
|
| 115 |
+
start, end = chunk['timestamp']
|
| 116 |
+
text = chunk['text'].strip()
|
| 117 |
+
|
| 118 |
f.write(f"{i}\n")
|
| 119 |
f.write(f"{format_srt_time(start)} --> {format_srt_time(end)}\n")
|
| 120 |
f.write(f"{text}\n\n")
|
| 121 |
+
else:
|
| 122 |
+
# Fallback if no chunks
|
| 123 |
+
f.write("1\n")
|
| 124 |
+
f.write("00:00:00,000 --> 00:00:10,000\n")
|
| 125 |
+
f.write(f"{transcription_result.get('text', '')}\n\n")
|
| 126 |
+
|
| 127 |
+
print(f"SRT file created with {len(transcription_result['chunks'])} entries")
|
| 128 |
+
|
| 129 |
+
except Exception as e:
|
| 130 |
+
print(f"Error creating SRT: {e}")
|
| 131 |
+
import traceback
|
| 132 |
+
print(traceback.format_exc())
|
| 133 |
+
raise
|
| 134 |
|
| 135 |
# Verify SRT was created and show preview
|
| 136 |
if not os.path.exists(srt_path):
|