summaryrefslogtreecommitdiff
path: root/scripts/local-whisper
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-11-04 14:35:50 -0600
committerCraig Jennings <c@cjennings.net>2025-11-04 14:35:50 -0600
commit45cab5c38dc089935416a89d36b461d9127094ac (patch)
treeccfb33579de009c8c8694f2a79d10e487d74de8f /scripts/local-whisper
parentefbcd0b7de7993b9fde29297daad1154711a3e81 (diff)
feat: Add complete async audio transcription workflow
Implemented full transcription system with local Whisper and OpenAI API support. Includes comprehensive test suite (60 tests) and reorganized keybindings for better discoverability. Features: - Async transcription (non-blocking workflow) - Desktop notifications (started/complete/error) - Output: audio.txt (transcript) + audio.log (process logs) - Modeline integration showing active transcription count - Dired integration (press T on audio files) - Process management and tracking Scripts: - install-whisper.sh: Install Whisper via AUR or pip - uninstall-whisper.sh: Clean removal with cache cleanup - local-whisper: Offline transcription using installed Whisper - oai-transcribe: Cloud transcription via OpenAI API Tests (60 passing): - Audio file detection (16 tests) - Path generation logic (11 tests) - Log cleanup behavior (5 tests) - Duration formatting (9 tests) - Active counter & modeline (11 tests) - Integration workflows (8 tests) Keybindings: - Reorganized gcal to C-; g submenu (s/t/r/c) - Added C-; t transcription submenu (t/b/k) - Dired: T to transcribe file at point 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'scripts/local-whisper')
-rwxr-xr-xscripts/local-whisper60
1 files changed, 60 insertions, 0 deletions
diff --git a/scripts/local-whisper b/scripts/local-whisper
new file mode 100755
index 00000000..b08651c9
--- /dev/null
+++ b/scripts/local-whisper
@@ -0,0 +1,60 @@
+#!/usr/bin/env bash
+# local-whisper - Transcribe audio files using locally installed Whisper
+# Usage: local-whisper <audio-file> [model] [language]
+#
+# Models: tiny, base, small, medium, large (default: small)
+# Language: en, es, fr, etc. (default: en)
+
+set -euo pipefail
+
+# Parse arguments
+AUDIO="${1:-}"
+MODEL="${2:-small}"
+LANG="${3:-en}"
+
+# Validate arguments
+if [[ -z "$AUDIO" ]]; then
+ echo "Usage: local-whisper <audio-file> [model] [language]" >&2
+ echo "Example: local-whisper meeting.m4a small en" >&2
+ exit 1
+fi
+
+if [[ ! -f "$AUDIO" ]]; then
+ echo "Error: Audio file not found: $AUDIO" >&2
+ exit 1
+fi
+
+# Check whisper is installed
+if ! command -v whisper &> /dev/null; then
+ echo "Error: whisper command not found" >&2
+ echo "Install with: ~/.emacs.d/scripts/install-whisper.sh" >&2
+ exit 1
+fi
+
+# Get absolute path to audio file
+AUDIO_ABS="$(realpath "$AUDIO")"
+AUDIO_DIR="$(dirname "$AUDIO_ABS")"
+AUDIO_BASE="$(basename "$AUDIO_ABS")"
+AUDIO_NAME="${AUDIO_BASE%.*}"
+
+# Run whisper
+# Note: whisper creates ${AUDIO_NAME}.txt automatically in the output directory
+whisper "$AUDIO_ABS" \
+ --model "$MODEL" \
+ --language "$LANG" \
+ --task transcribe \
+ --output_format txt \
+ --output_dir "$AUDIO_DIR" \
+ --verbose False 2>&1
+
+# Output file that whisper creates
+OUTPUT_FILE="$AUDIO_DIR/$AUDIO_NAME.txt"
+
+# Return transcript to stdout
+if [[ -f "$OUTPUT_FILE" ]]; then
+ cat "$OUTPUT_FILE"
+ exit 0
+else
+ echo "Error: Whisper did not create expected output file: $OUTPUT_FILE" >&2
+ exit 1
+fi