Commit
Β·
462db13
1
Parent(s):
11a77dd
Fixed file validation to use original filename
Browse files
app.py
CHANGED
@@ -72,16 +72,16 @@ with gr.Blocks(theme=gr.themes.Monochrome(), css=css) as demo:
|
|
72 |
|
73 |
def generate_subtitles(video_file, language):
|
74 |
try:
|
75 |
-
# Validate
|
76 |
-
if not video_file.
|
77 |
return None, "β Invalid file type. Please upload an MP4, MKV, or AVI file."
|
78 |
|
79 |
# Initialize progress tracking
|
80 |
progress = gr.Progress(track_tqdm=True)
|
81 |
|
82 |
-
# Process video
|
83 |
progress(0, desc="Initializing...")
|
84 |
-
srt_path = process_video(video_file.name, language, progress=progress)
|
85 |
if srt_path:
|
86 |
progress(1, desc="β
Subtitles generated successfully!")
|
87 |
return gr.File(srt_path), "β
Subtitles ready for download!"
|
|
|
72 |
|
73 |
def generate_subtitles(video_file, language):
|
74 |
try:
|
75 |
+
# Validate original filename (not the temporary path)
|
76 |
+
if not video_file.orig_name.lower().endswith(('.mp4', '.mkv', '.avi')):
|
77 |
return None, "β Invalid file type. Please upload an MP4, MKV, or AVI file."
|
78 |
|
79 |
# Initialize progress tracking
|
80 |
progress = gr.Progress(track_tqdm=True)
|
81 |
|
82 |
+
# Process video using the temporary file path
|
83 |
progress(0, desc="Initializing...")
|
84 |
+
srt_path = process_video(video_file.name, language, progress=progress) # Use video_file.name for processing
|
85 |
if srt_path:
|
86 |
progress(1, desc="β
Subtitles generated successfully!")
|
87 |
return gr.File(srt_path), "β
Subtitles ready for download!"
|