Pushkar0655g commited on
Commit
462db13
Β·
1 Parent(s): 11a77dd

Fixed file validation to use original filename

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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 file type
76
- if not video_file.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
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!"