Initial commit
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
# Entry point for the mknotes audio transcription and note enhancement tool
|
||||
|
||||
import os
|
||||
from tqdm import tqdm
|
||||
|
||||
from src.cli import parse_args
|
||||
from src.utils import find_audio_files, ensure_directory_exists
|
||||
from src.transcriber import transcribe_audio
|
||||
from src.enhancer import enhance_note
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
input_dir = args.input_dir
|
||||
output_dir = args.output_dir
|
||||
model_size = args.model_size
|
||||
|
||||
ensure_directory_exists(output_dir)
|
||||
|
||||
audio_files = find_audio_files(input_dir)
|
||||
if not audio_files:
|
||||
print(f"No audio files found in {input_dir}.")
|
||||
return
|
||||
|
||||
print(f"Found {len(audio_files)} audio files. Starting transcription and enhancement...")
|
||||
|
||||
for audio_path in tqdm(audio_files, desc="Processing files"):
|
||||
base_name = os.path.splitext(os.path.basename(audio_path))[0]
|
||||
txt_path = os.path.join(output_dir, base_name + ".txt")
|
||||
md_path = os.path.join(output_dir, base_name + ".md")
|
||||
|
||||
# Skip if enhanced note already exists (unless force flag is set)
|
||||
if os.path.exists(md_path) and not args.force:
|
||||
print(f"Skipping {audio_path} - enhanced note already exists at {md_path}")
|
||||
continue
|
||||
|
||||
# Check if transcription exists
|
||||
if os.path.exists(txt_path) and not args.force:
|
||||
print(f"Using existing transcription for {audio_path}")
|
||||
with open(txt_path, "r", encoding="utf-8") as f:
|
||||
transcription = f.read()
|
||||
else:
|
||||
# Transcribe audio
|
||||
transcription = transcribe_audio(
|
||||
audio_path,
|
||||
txt_path,
|
||||
model_size=model_size,
|
||||
turbo=args.turbo
|
||||
)
|
||||
|
||||
# Enhance note (only if md file doesn't exist or force flag is set)
|
||||
if not os.path.exists(md_path) or args.force:
|
||||
try:
|
||||
enhanced_note = enhance_note(transcription)
|
||||
with open(md_path, "w", encoding="utf-8") as f:
|
||||
f.write(enhanced_note)
|
||||
except Exception as e:
|
||||
print(f"Error enhancing note for {audio_path}: {e}")
|
||||
|
||||
print(f"Processing complete. Output saved to: {output_dir}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user