From 45cab5c38dc089935416a89d36b461d9127094ac Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 4 Nov 2025 14:35:50 -0600 Subject: feat: Add complete async audio transcription workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- scripts/local-whisper | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 scripts/local-whisper (limited to 'scripts/local-whisper') 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 [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 [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 -- cgit v1.2.3