artificialguybr commited on
Commit
b1d37b8
1 Parent(s): da0e3ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -26,8 +26,14 @@ def process_video(video, high_quality, target_language):
26
  if not os.path.exists(video_path):
27
  return f"Error: {video_path} does not exist."
28
 
29
- audio_output = os.path.join(temp_dir, "output_audio.wav")
30
- ffmpeg.input(video_path).output(audio_output, acodec='pcm_s24le', ar=48000, map='a', y=True).run()
 
 
 
 
 
 
31
 
32
  y, sr = sf.read("output_audio.wav")
33
  y = y.astype(np.float32)
 
26
  if not os.path.exists(video_path):
27
  return f"Error: {video_path} does not exist."
28
 
29
+ with tempfile.TemporaryDirectory() as temp_dir:
30
+ audio_output = os.path.join(temp_dir, "output_audio.wav")
31
+
32
+ try:
33
+ ffmpeg.input(video_path).output(audio_output, acodec='pcm_s24le', ar=48000, map='a').run()
34
+ except ffmpeg.Error as e:
35
+ return f"FFmpeg error: {e.stderr.decode('utf-8')}"
36
+
37
 
38
  y, sr = sf.read("output_audio.wav")
39
  y = y.astype(np.float32)