diff --git a/transcribe.py b/transcribe.py index 0e6eedb..f5b13f9 100644 --- a/transcribe.py +++ b/transcribe.py @@ -1,13 +1,25 @@ #!/usr/bin/env python3 import sys import whisper +import os if len(sys.argv) < 2: - print("Usage: python transcribe.py [language]") + print("Usage: python transcribe.py [language]") print("Example: python transcribe.py audio.mp3 es") sys.exit(1) +filename = sys.argv[1] +ext = os.path.splitext(filename)[1].lower() +video_exts = {'.mp4', '.avi', '.mov', '.mkv', '.flv', '.wmv', '.webm'} + +if ext in video_exts: + print(f"Error: Video files ({ext}) are not allowed per DEVELOPMENT_RULES.md.") + print("Please extract audio first (e.g., using ffmpeg -i input.mp4 -vn -acodec libmp3lame output.mp3)") + sys.exit(1) + +print(f"Transcribing {filename}...") model = whisper.load_model("base") language = sys.argv[2] if len(sys.argv) > 2 else None -result = model.transcribe(sys.argv[1], language=language) +result = model.transcribe(filename, language=language) +print("-" * 20) print(result["text"])