diff --git a/app.py b/app.py index 4ec923a..2ad93e8 100644 --- a/app.py +++ b/app.py @@ -1,5 +1,6 @@ import os import shutil +import time import gradio as gr from pathlib import Path import google.generativeai as genai @@ -12,6 +13,10 @@ model = genai.GenerativeModel('models/gemini-1.5-flash') +# Create main output directories for segmented audios. +segment_folder = Path("segments/") +segment_folder.mkdir(exist_ok=True) + def process_audio(audio_file, should_summarize): """Process audio file: convert, segment, transcribe and optionally summarize""" try: @@ -23,16 +28,21 @@ def process_audio(audio_file, should_summarize): output_wav_name = Path(audio_file.name).stem + '.wav' output_wav_path = str(Path(input_path).parent / output_wav_name) - # Create output directories - segment_folder = Path("segments/") - segment_folder.mkdir(exist_ok=True) - # Process audio print(f"Converting {input_path} to {output_wav_path}") convert_mp4_to_wav(input_path) # This should output to output_wav_path + + # Create output dir based on current timestamp for converted audio. + current_time = time.strftime("%Y%m%d-%H%M") + current_time_segment_folder = segment_folder / current_time + os.makedirs(current_time_segment_folder, exist_ok=True) + + # Create folder for segmented audios. + segment_audios_folder = current_time_segment_folder / output_wav_name + os.makedirs(segment_audios_folder, exist_ok=True) print(f"Splitting audio from {output_wav_path}") - split_audio(output_wav_path, str(segment_folder)) + split_audio(output_wav_path, str(segment_audios_folder)) # Transcribe print("Transcribing segments...") diff --git a/requirements.txt b/requirements.txt index dd06051..48599c3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,6 @@ -json python-docx tqdm gradio -csv -textwrap BeautifulSoup4 markdown pandas