From cc82469ef9513a616bde2addf831598ac735c9cc Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 6 May 2024 20:42:05 -0700 Subject: [PATCH] ffmpeg print statements + fixes --- .gitignore | Bin 6846 -> 6852 bytes diarize.py | 33 +++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index cefc7add77df82b530a55a2614dfba11ca5bdd21..95fffd12ea1e79a256f66dfcbceaf445a5f9bec9 100644 GIT binary patch delta 14 VcmdmIdc<_YJ}EYRr_4MfE&wdz1pfd4 delta 7 OcmX?Ny3cgOJ}CeW(F1h= diff --git a/diarize.py b/diarize.py index c24a39c..35b2937 100644 --- a/diarize.py +++ b/diarize.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import argparse, configparser, datetime, json, logging, os, platform, requests, shutil, subprocess, sys, time, unicodedata +import zipfile from datetime import datetime import contextlib import ffmpeg # Used for issuing commands to underlying ffmpeg executable, pip package ffmpeg is from 2018 @@ -137,6 +138,7 @@ print(r"""_____ _ ________ _ _ # Perform Platform Check userOS = "" def platform_check(): + global userOS if platform.system() == "Linux": print("Linux OS detected \n Running Linux appropriate commands") userOS = "Linux" @@ -191,16 +193,16 @@ def check_ffmpeg(): else: logging.debug("ffmpeg not installed on the local system/in local PATH") print("ffmpeg is not installed.\n\n You can either install it manually, or through your package manager of choice.\n Windows users, builds are here: https://www.gyan.dev/ffmpeg/builds/") - if userOS == "Windows": - download_ffmpeg() - elif userOS == "Linux": - print("You should install ffmpeg using your platform's appropriate package manager, 'apt install ffmpeg','dnf install ffmpeg' or 'pacman', etc.") - else: - logging.debug("running an unsupported OS") - print("You're running an unspported/Un-tested OS") - exit_script = input("Let's exit the script, unless you're feeling lucky? (y/n)") - if exit_script == "y" or "yes" or "1": - exit() + if userOS == "Windows": + download_ffmpeg() + elif userOS == "Linux": + print("You should install ffmpeg using your platform's appropriate package manager, 'apt install ffmpeg','dnf install ffmpeg' or 'pacman', etc.") + else: + logging.debug("running an unsupported OS") + print("You're running an unspported/Un-tested OS") + exit_script = input("Let's exit the script, unless you're feeling lucky? (y/n)") + if exit_script == "y" or "yes" or "1": + exit() @@ -208,17 +210,19 @@ def check_ffmpeg(): def download_ffmpeg(): user_choice = input("Do you want to download ffmpeg? (yes/no): ") if user_choice.lower() == 'yes' or 'y' or '1': - # Download the zip file + print("Downloading ffmpeg") url = "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip" response = requests.get(url) if response.status_code == 200: + print("Saving ffmpeg zip file") logging.debug("Saving ffmpeg zip file") zip_path = "ffmpeg-release-essentials.zip" with open(zip_path, 'wb') as file: file.write(response.content) logging.debug("Extracting the 'ffmpeg.exe' file from the zip") + print("Extracting ffmpeg.exe from zip file to '/Bin' folder") with zipfile.ZipFile(zip_path, 'r') as zip_ref: ffmpeg_path = "ffmpeg-7.0-essentials_build/bin/ffmpeg.exe" @@ -236,11 +240,12 @@ def download_ffmpeg(): dst_path = os.path.join(bin_folder, "ffmpeg.exe") shutil.move(src_path, dst_path) - # Remove the downloaded zip file + logging.debug("Removing ffmpeg zip file") + print("Deleting zip file (we've already extracted ffmpeg.exe, no worries)") os.remove(zip_path) logging.debug("ffmpeg.exe has been downloaded and extracted to the './Bin' folder.") - print("ffmpeg.exe has been downloaded and extracted to the './Bin' folder.") + print("ffmpeg.exe has been successfully downloaded and extracted to the './Bin' folder.") else: logging.error("Failed to download the zip file.") print("Failed to download the zip file.") @@ -923,7 +928,7 @@ if __name__ == "__main__": logging.info('Starting the transcription and summarization process.') logging.info(f'Input path: {args.input_path}') logging.info(f'API Name: {args.api_name}') - logging.debug(f'API Key: {api_key}') # ehhhhh + logging.debug(f'API Key: {args.api_key}') # ehhhhh logging.info(f'Number of speakers: {args.num_speakers}') logging.info(f'Whisper model: {args.whisper_model}') logging.info(f'Offset: {args.offset}')