aboutsummaryrefslogtreecommitdiff
path: root/tests/test-transcription-status-and-commands.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-14 14:09:16 -0500
committerCraig Jennings <c@cjennings.net>2026-05-14 14:09:16 -0500
commit4a7529393ebbbc225939f21be783ec624d0a8168 (patch)
treeece00458140ecac7a590b826e7e7a1917fa844e9 /tests/test-transcription-status-and-commands.el
parentd914f1d0fc134356065416d1f489a577b8ffa1bd (diff)
downloaddotemacs-4a7529393ebbbc225939f21be783ec624d0a8168.tar.gz
dotemacs-4a7529393ebbbc225939f21be783ec624d0a8168.zip
feat(transcription): extend dired T to transcribe videos via ffmpeg, with tests
Pressing `T' in dired/dirvish on an audio file already transcribed it; on a video file it bounced with "Not an audio file". Real recordings ship as .mp4 / .mkv at least as often as raw .m4a, so the one-key flow ended at the wrong place. Pipeline now: - audio path -> direct into `cj/--start-transcription-process' (unchanged). - video path -> async ffmpeg extracts the audio track to a temp .mp3 under `temporary-file-directory' (libmp3lame, VBR q:a 4, ~165kbps -- right size for speech, accepted by every backend), then transcribes that file with the temp marked for cleanup after the transcription sentinel fires. Surface changes: - `cj/video-file-extensions' added to user-constants.el (mp4, mkv, mov, webm, avi, m4v, wmv, flv, mpg, mpeg, 3gp, ogv). - New predicates `cj/--video-file-p' / `cj/--media-file-p'. - New `cj/--extract-audio-from-video' (async ffmpeg with success callback; surfaces `cj/--notify' on failure; user-errors if ffmpeg isn't on PATH). - `cj/--start-transcription-process' gains optional `cleanup-file'. Sentinel deletes it after the existing logic runs. Backwards compatible -- the audio flow doesn't pass it. - `cj/transcribe-audio' renamed to `cj/transcribe-media' (dispatcher on audio vs video). `cj/transcribe-audio-at-point' renamed to `cj/transcribe-media-at-point'. Both old names kept as `defalias' so M-x history and any external references still work. - `T' in dired-mode-map + dirvish-mode-map points at `cj/transcribe-media-at-point'. - Module commentary USAGE block updated. 15 new ERT tests in `tests/test-transcription-video.el' cover the predicates (happy/boundary/error), ffmpeg invocation (correct args + missing-ffmpeg path), the dispatcher (audio direct, video via extraction, non-media rejected), the aliases, and the T binding. One existing test in `test-transcription-status-and-commands.el' updated to stub the new delegate name. Verified locally that ffmpeg is on PATH with libmp3lame, and that the exact arg list my code uses produces a valid MP3 from a synthetic test video.
Diffstat (limited to 'tests/test-transcription-status-and-commands.el')
-rw-r--r--tests/test-transcription-status-and-commands.el9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/test-transcription-status-and-commands.el b/tests/test-transcription-status-and-commands.el
index 90841e70..7c796de0 100644
--- a/tests/test-transcription-status-and-commands.el
+++ b/tests/test-transcription-status-and-commands.el
@@ -179,13 +179,18 @@
(should-error (cj/transcribe-audio-at-point) :type 'user-error)))
(ert-deftest test-tx-transcribe-audio-at-point-normal-delegates ()
- "Normal: with a file at point, delegates to `cj/transcribe-audio'."
+ "Normal: with a file at point, delegates to `cj/transcribe-media'.
+
+`cj/transcribe-audio-at-point' is now a `defalias' for
+`cj/transcribe-media-at-point', which hands off to
+`cj/transcribe-media' (no longer the old audio-only command). The
+stub still pins behavior by name."
(let ((handed-off nil))
(cl-letf (((symbol-function 'derived-mode-p)
(lambda (&rest modes) (memq 'dired-mode modes)))
((symbol-function 'dired-get-filename)
(lambda (&rest _) "/tmp/recording.wav"))
- ((symbol-function 'cj/transcribe-audio)
+ ((symbol-function 'cj/transcribe-media)
(lambda (f) (setq handed-off f))))
(cj/transcribe-audio-at-point))
(should (equal handed-off "/tmp/recording.wav"))))