Logging is broken...?

This commit is contained in:
Robert
2024-05-11 23:25:53 -07:00
parent daad6584b8
commit 0aea6979a7
2 changed files with 13 additions and 8 deletions

View File

@@ -222,7 +222,7 @@ def decide_cpugpu():
# check for existence of ffmpeg
def check_ffmpeg():
if shutil.which("ffmpeg") or (os.path.exists("Bin") and os.path.isfile(".\\Bin\\ffmpeg.exe")):
if shutil.which("ffmpeg") or (os.path.exists("..\\Bin") and os.path.isfile("..\\Bin\\ffmpeg.exe")):
logging.debug("ffmpeg found installed on the local system, in the local PATH, or in the './Bin' folder")
pass
else:
@@ -488,7 +488,7 @@ def download_video(video_url, download_path, info_dict, download_video_flag):
if userOS == "Windows":
logging.debug("Running ffmpeg on Windows...")
ffmpeg_command = [
'.\\Bin\\ffmpeg.exe',
'..\\Bin\\ffmpeg.exe',
'-i', video_file_path,
'-i', audio_file_path,
'-c:v', 'copy',
@@ -886,7 +886,6 @@ def summarize_with_claude(api_key, file_path, model, custom_prompt):
# Summarize with Cohere
def summarize_with_cohere(api_key, file_path, model, custom_prompt):
try:
logging.basicConfig(level=logging.DEBUG)
logging.debug("cohere: Loading JSON data")
with open(file_path, 'r') as file:
segments = json.load(file)
@@ -1242,6 +1241,7 @@ def format_file_path(file_path):
return file_path if file_path and os.path.exists(file_path) else None
def launch_ui(demo_mode=False):
logging.info('Inside launch_ui() function')
inputs = [
gr.components.Textbox(label="URL", placeholder="Enter the video URL here"),
gr.components.Number(value=2, label="Number of Speakers"),
@@ -1267,6 +1267,7 @@ def launch_ui(demo_mode=False):
def process_url(url, num_speakers, whisper_model, custom_prompt, offset, api_name, api_key, vad_filter,
download_video):
video_file_path = None
logging.debug(f"API Key in process_url: {api_key}")
try:
results = main(url, api_name=api_name, api_key=api_key, num_speakers=num_speakers,
whisper_model=whisper_model, offset=offset, vad_filter=vad_filter,
@@ -1438,6 +1439,7 @@ def main(input_path, api_name=None, api_key=None, num_speakers=2, whisper_model=
json_file_path = audio_file.replace('.wav', '.segments.json')
if api_name.lower() == 'openai':
api_key = openai_api_key
logging.debug(f"MAIN: API Key in main: {api_key}")
try:
logging.debug(f"MAIN: trying to summarize with openAI")
summary = summarize_with_openai(api_key, json_file_path, openai_model, custom_prompt)
@@ -1527,15 +1529,16 @@ if __name__ == "__main__":
help='Whisper model (default: small.en)')
parser.add_argument('-off', '--offset', type=int, default=0, help='Offset in seconds (default: 0)')
parser.add_argument('-vad', '--vad_filter', action='store_true', help='Enable VAD filter')
parser.add_argument('-log', '--log_level', type=str, default='INFO',
choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], help='Log level (default: INFO)')
# Give app.py verbose logging - DEBUG
parser.add_argument('-log', '--log_level', type=str, default='DEBUG',
choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], help='Log level (default: DEBUG)')
parser.add_argument('-ui', '--user_interface', action='store_true', help='Launch the Gradio user interface')
parser.add_argument('-demo', '--demo_mode', action='store_true', help='Enable demo mode')
parser.add_argument('-prompt', '--custom_prompt', type=str,
help='Pass in a custom prompt to be used in place of the existing one.(Probably should just modify the script itself...)')
# parser.add_argument('--log_file', action=str, help='Where to save logfile (non-default)')
args = parser.parse_args()
logging.basicConfig(level=getattr(logging, args.log_level), format='%(asctime)s - %(levelname)s - %(message)s')
custom_prompt = args.custom_prompt
if custom_prompt == "":
logging.debug(f"Custom prompt defined, will use \n\nf{custom_prompt} \n\nas the prompt")
@@ -1553,6 +1556,8 @@ if __name__ == "__main__":
# Since this is running in HF....
args.user_interface = True
if args.user_interface:
logging.basicConfig(level=getattr(logging, args.log_level), format='%(asctime)s - %(levelname)s - %(message)s')
logging.debug('Logging configured')
launch_ui(demo_mode=args.demo_mode)
else:
if not args.input_path:
@@ -1560,11 +1565,10 @@ if __name__ == "__main__":
sys.exit(1)
logging.basicConfig(level=getattr(logging, args.log_level), format='%(asctime)s - %(levelname)s - %(message)s')
logging.debug('Logging configured')
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: {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}')

View File

@@ -1439,6 +1439,7 @@ if __name__ == "__main__":
print("No custom prompt defined, will use default")
if args.user_interface:
logging.basicConfig(level=getattr(logging, args.log_level), format='%(asctime)s - %(levelname)s - %(message)s')
launch_ui(demo_mode=False)
else:
if not args.input_path: