f201ef509d
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
26 lines
808 B
Python
26 lines
808 B
Python
#!/usr/bin/env python3
|
|
import sys
|
|
import whisper
|
|
import os
|
|
|
|
if len(sys.argv) < 2:
|
|
print("Usage: python transcribe.py <audio_file> [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(filename, language=language)
|
|
print("-" * 20)
|
|
print(result["text"])
|