From 19abb658604173c7d3ee0e691d768f62ce927d25 Mon Sep 17 00:00:00 2001 From: Tanishq Dubey Date: Sat, 18 Feb 2023 22:26:48 -0500 Subject: [PATCH] add requirements and ffmpeg setup --- main.py | 4 ++++ requirements.txt | 8 ++++++++ src/utils/__init__.py | 0 src/utils/prereq.py | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 requirements.txt create mode 100644 src/utils/__init__.py create mode 100644 src/utils/prereq.py diff --git a/main.py b/main.py index e2684d5..f15b30e 100644 --- a/main.py +++ b/main.py @@ -11,6 +11,10 @@ import time import numpy as np +from src.utils.prereq import check_ffmpeg, install_ffmpeg + +check_ffmpeg() + from src.mediautils.audio import extract_audio_from_video from src.mediautils.video import render_moments, filter_moments from src.editors.amplitude.editor import AmplitudeEditor diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b73eafb --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +structlog==22.3.0 +rich==13.3.1 +numpy==1.24.2 +moviepy==1.0.3 +scipy==1.10.0 +openai-whisper==20230124 +flair==0.11.3 +click==8.1.3 diff --git a/src/utils/__init__.py b/src/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/prereq.py b/src/utils/prereq.py new file mode 100644 index 0000000..e9b9231 --- /dev/null +++ b/src/utils/prereq.py @@ -0,0 +1,35 @@ +import os +import platform +import subprocess +import structlog +import click +import sys + +log = structlog.get_logger() + + +def install_ffmpeg(): + if not click.confirm('Do you want to install ffmpeg? It is required for ALE.', default=False): + log.warn("ffmpeg not installed. Please install it manually or restart ALE. Exiting...") + sys.exit(0) + system = platform.system().lower() + if system == "linux": + package_manager = "apt-get" if os.path.exists("/etc/apt/sources.list") else "yum" + command = f"sudo {package_manager} install -y ffmpeg" + elif system == "darwin": + command = "brew install ffmpeg" + else: + raise Exception(f"Unsupported operating system: {system}") + try: + subprocess.check_call(command.split()) + print("ffmpeg has been installed successfully!") + except subprocess.CalledProcessError as e: + print(f"An error occurred while installing ffmpeg: {e}") + + +def check_ffmpeg(): + try: + subprocess.check_call(["ffmpeg", "-version"], stdout=subprocess.DEVNULL) + except (subprocess.CalledProcessError, FileNotFoundError): + log.info("ffmpeg is not installed.") + install_ffmpeg()