diff options
| author | Craig Jennings <c@cjennings.net> | 2025-11-04 14:35:50 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-11-04 14:35:50 -0600 |
| commit | 45cab5c38dc089935416a89d36b461d9127094ac (patch) | |
| tree | ccfb33579de009c8c8694f2a79d10e487d74de8f /scripts/oai-transcribe | |
| parent | efbcd0b7de7993b9fde29297daad1154711a3e81 (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/oai-transcribe')
| -rwxr-xr-x | scripts/oai-transcribe | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/oai-transcribe b/scripts/oai-transcribe new file mode 100755 index 00000000..f64a8122 --- /dev/null +++ b/scripts/oai-transcribe @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# oai-transcribe - Transcribe audio files using OpenAI Whisper API +# Usage: oai-transcribe <audio-file> [language] +# +# Requires: OPENAI_API_KEY environment variable +# Language: en, es, fr, etc. (default: en) + +set -euo pipefail + +# Parse arguments +AUDIO="${1:-}" +LANG="${2:-en}" + +# Validate arguments +if [[ -z "$AUDIO" ]]; then + echo "Usage: oai-transcribe <audio-file> [language]" >&2 + echo "Example: oai-transcribe meeting.m4a en" >&2 + exit 1 +fi + +if [[ ! -f "$AUDIO" ]]; then + echo "Error: Audio file not found: $AUDIO" >&2 + exit 1 +fi + +# Check API key is set +if [[ -z "${OPENAI_API_KEY:-}" ]]; then + echo "Error: OPENAI_API_KEY environment variable not set" >&2 + echo "Set with: export OPENAI_API_KEY='sk-...'" >&2 + exit 1 +fi + +# Check curl is available +if ! command -v curl &> /dev/null; then + echo "Error: curl command not found" >&2 + exit 1 +fi + +# Call OpenAI API +curl -s -X POST "https://api.openai.com/v1/audio/transcriptions" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -F "model=whisper-1" \ + -F "response_format=text" \ + -F "language=${LANG}" \ + -F "file=@${AUDIO}" |
