ruslanmv commited on
Commit
789426a
·
verified ·
1 Parent(s): ddf7d79

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -21
app.py CHANGED
@@ -11,6 +11,7 @@ import textwrap
11
  import os
12
  import glob
13
  import subprocess
 
14
 
15
  # Ensure 'punkt' is downloaded for nltk
16
  try:
@@ -18,28 +19,15 @@ try:
18
  except LookupError:
19
  nltk.download('punkt')
20
 
21
- # Function to check and install FFmpeg if not found
22
- def ensure_ffmpeg_installed():
23
- try:
24
- # Check if FFmpeg is installed by running ffmpeg -version
25
- subprocess.run(['ffmpeg', '-version'], check=True, capture_output=True, text=True)
26
- print("FFmpeg is already installed.")
27
- except (subprocess.CalledProcessError, FileNotFoundError):
28
- print("FFmpeg not found. Attempting to install...")
29
- try:
30
- # Install FFmpeg using the system package manager (apt for Debian/Ubuntu)
31
- subprocess.run(['apt', 'update'], check=True)
32
- subprocess.run(['apt', 'install', '-y', 'ffmpeg'], check=True)
33
- print("FFmpeg installed successfully using apt.")
34
- except subprocess.CalledProcessError as e:
35
- print(f"Failed to install FFmpeg using apt: {e}")
36
- print("Please install FFmpeg manually and ensure it is in your system's PATH.")
37
- raise
38
-
39
- # Ensure FFmpeg is installed before proceeding
40
- ensure_ffmpeg_installed()
41
 
42
- description = " Video Story Generator with Audio \n PS: Generation of video by using Artificial Intelligence by dalle-mini and distilbart and gtss "
43
  title = "Video Story Generator with Audio by using dalle-mini and distilbart and gtss "
44
 
45
  tokenizer = AutoTokenizer.from_pretrained("sshleifer/distilbart-cnn-12-6")
 
11
  import os
12
  import glob
13
  import subprocess
14
+ import imageio_ffmpeg
15
 
16
  # Ensure 'punkt' is downloaded for nltk
17
  try:
 
19
  except LookupError:
20
  nltk.download('punkt')
21
 
22
+ # Download FFmpeg using imageio_ffmpeg (more robust)
23
+ try:
24
+ imageio_ffmpeg.get_ffmpeg_exe()
25
+ print("FFmpeg downloaded successfully (if not already present).")
26
+ except Exception as e:
27
+ print(f"Error downloading FFmpeg using imageio_ffmpeg: {e}")
28
+ raise
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
+ description = "Video Story Generator with Audio \n PS: Generation of video by using Artificial Intelligence by dalle-mini and distilbart and gtss "
31
  title = "Video Story Generator with Audio by using dalle-mini and distilbart and gtss "
32
 
33
  tokenizer = AutoTokenizer.from_pretrained("sshleifer/distilbart-cnn-12-6")