Artificial-superintelligence commited on
Commit
40ffd8f
·
verified ·
1 Parent(s): 9392609

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -30
app.py CHANGED
@@ -86,11 +86,15 @@ class VideoProcessor:
86
  # Extract audio to temporary file
87
  audio_path = self.create_temp_path(".wav")
88
  video.audio.write_audiofile(audio_path, fps=16000, verbose=False, logger=None)
89
-
 
 
 
 
90
  # Transcribe using Whisper
91
  result = self.whisper_model.transcribe(audio_path)
92
  return result["segments"], video.duration
93
-
94
  except Exception as e:
95
  raise Exception(f"Transcription error: {str(e)}")
96
 
@@ -202,7 +206,7 @@ def process_video(video_data, voice_type, generate_subtitles=True, subtitle_size
202
  progress_text.text("Creating final video...")
203
 
204
  # Combine audio clips
205
- final_audio = CompositeVideoClip([*audio_clips])
206
 
207
  # Create final video
208
  if generate_subtitles:
@@ -272,33 +276,17 @@ def main():
272
  # Process video
273
  if st.button("Start Dubbing"):
274
  try:
275
- with st.spinner("Processing video..."):
276
- output_path = process_video(
277
- video_file.read(),
278
- voice_type,
279
- generate_subtitles,
280
- subtitle_size if generate_subtitles else 24,
281
- subtitle_color if generate_subtitles else 'white'
282
- )
283
-
284
- # Show success message
285
- st.success("டப்பிங் வெற்றிகரமாக முடிந்தது!")
286
-
287
- # Display video
288
- st.video(output_path)
289
-
290
- # Download button
291
- with open(output_path, "rb") as f:
292
- st.download_button(
293
- "⬇️ Download Dubbed Video",
294
- f,
295
- file_name="tamil_dubbed_video.mp4",
296
- mime="video/mp4"
297
- )
298
-
299
  except Exception as e:
300
- st.error(f"Processing failed: {str(e)}")
301
- st.error("Please try uploading a different video or check if the format is supported.")
302
 
303
  if __name__ == "__main__":
304
- main()
 
86
  # Extract audio to temporary file
87
  audio_path = self.create_temp_path(".wav")
88
  video.audio.write_audiofile(audio_path, fps=16000, verbose=False, logger=None)
89
+
90
+ # Check if audio file is not empty
91
+ if os.path.getsize(audio_path) == 0:
92
+ raise ValueError("Extracted audio file is empty")
93
+
94
  # Transcribe using Whisper
95
  result = self.whisper_model.transcribe(audio_path)
96
  return result["segments"], video.duration
97
+
98
  except Exception as e:
99
  raise Exception(f"Transcription error: {str(e)}")
100
 
 
206
  progress_text.text("Creating final video...")
207
 
208
  # Combine audio clips
209
+ final_audio = concatenate_audioclips(audio_clips)
210
 
211
  # Create final video
212
  if generate_subtitles:
 
276
  # Process video
277
  if st.button("Start Dubbing"):
278
  try:
279
+ output_video_path = process_video(
280
+ video_file.read(),
281
+ voice_type,
282
+ generate_subtitles=generate_subtitles,
283
+ subtitle_size=subtitle_size,
284
+ subtitle_color=subtitle_color
285
+ )
286
+ st.success("Video processing complete!")
287
+ st.video(output_video_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  except Exception as e:
289
+ st.error(f"Error: {e}")
 
290
 
291
  if __name__ == "__main__":
292
+ main()