-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
51 lines (40 loc) · 1.65 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
# src/babelscribe/main.py
import os
from dotenv import load_dotenv
from utils import load_config, ensure_folders_exist, save_results
from transcribe import process_audio_file
from summarize import summarize_text
def main():
# Load environment variables
load_dotenv()
# Load configuration
try:
config = load_config()
except Exception as e:
print(f"Error loading configuration: {e}")
return
# Ensure necessary folders exist
ensure_folders_exist(config)
# Get language input from user
language = input("Enter the language code for all files (optional, press Enter to skip): ").strip() or None
# Process audio files
input_folder = config['input_folder']
for file_name in os.listdir(input_folder):
if file_name.lower().endswith(('.flac', '.mp3', '.mp4', '.mpeg', '.mpga', '.m4a', '.ogg', '.wav', '.webm')):
print(f"Processing {file_name}...")
try:
# Transcribe audio
transcription = process_audio_file(file_name, config, language)
print("Transcription complete.")
# Summarize transcription
summary = summarize_text(transcription, config)
print("Summary complete.")
# Save results
output_path = save_results(file_name, transcription, summary, config)
print(f"Results saved to {output_path}")
except Exception as e:
print(f"Error processing {file_name}: {str(e)}")
print("All files processed.")
if __name__ == "__main__":
main()