Categories: geek » emacs » subed

View topic page - RSS - Atom - Subscribe via email

Fixing commonly-misrecognized words in dictation, voice commands, and regular text

| audio, subed, emacs, speech-recognition

I edit a lot of transcripts, and I've also been dictating to my computer more and more for both prose and voice commands. Speech recognition is pretty accurate, but there are some terms that it tends to get wrong. There are also some terms that I find hard to say, like sometimes my brain will just hiccup and I'll end up saying "start screaming" instead of "start streaming". I want to make it really easy to correct a misrecognized word throughout my current buffer and save it for future edits.

One of the advantages of doing this kind of replacement within Emacs instead of a separate dictation tool is that I can use it for both editing text (like transcripts of other people's presentations) as well as pre-process the speech recognition results when I dictate or use voice commands to control Emacs. I can even use it to start gradually getting my transcripts to follow Emacs keybinding conventions, like C-c instead of "control c", and for finicky capitalization like LaTeX.

1. Description and demo

You can watch a description and a demo here. The dictionary part starts at about 00:37:01.403.

Full video and transcript

Or as a YouTube short: Emacs Speech-to-Text That Learns From Its Mistakes - Sacha Chua - YouTube.

2. Saving the dictionary

First, we define a variable that we're going to save the changes to.

;; Use the saved version of this instead of forcing the reevaluation
;;;###autoload
(defcustom sacha-subed-common-edits
  '("I"
    "I've"
    "I'm"
    "Mendeley"
    "JavaScript"
    "RSS"
    ("stop section" "subsection")
    ("EmacsConf" "EmacsCon" "EmacsConf" "imaxconf")
    ("going to" "gonna")
    ("want to" "wanna")
    ("transient" "transit")
    ("C-c" "control c" "Ctrl+C")
    ("C-x" "control x" "Ctrl+X")
    ("C-f" "control f")
    ("" "uh" "um")
    ("Magit" "maggot")
    ("Emacs" "e-max" "emex" "emax" "bmx" "imax")
    ("Emacs News" "emacs news")
    ("Emacs Lisp" "emacs list")
    ("ivy" "iv")
    ("UI" "ui")
    ("TECO" "tico")
    ("org-roam" "orgrim" "orgrom" "Org Rome")
    ("non-nil" "non-nail")
    ("commits" "comets")
    "SQL"
    "arXiv"
    "Montessori"
    "SVG"
    "YouTube" "GitHub" "GitLab" "OmegaT" "Linux" "SourceForge"
    "LaTeX"
    "Lisp"
    "Org"
    "IRC"
    "Reddit"
    "PowerPoint"
    "SQLite"
    "SQL"
    "I'll"
    ("<f9>" "F-9" "f9")
    "I'd"
    "PDFs"
    "PDF"
    "ASCII"
    ("Spacemacs" "spacemax")
    "Elisp"
    "Reddit"
    "TextMate"
    "macOS"
    "API"
    "IntelliSense"
    ("EXWM" "axwm")
    ("Emacs's" "emax's")
    ("BIDI" "bd")
    ("Perso-Arabic" "personal arabic")
    "Persian"
    "URL"
    "HTML"
    ("vdo.ninja" "Video Ninja"))
  "Commonly-misrecognized words or words that need special capitalization."
  :group 'sachac
  :type '(repeat (choice string
                         (repeat string))))

3. Making changes with substitute.el

I like using Prot's substitute.el. I bind substitute-target-in-buffer to C-; . I can either replace the current word or select a couple of words if I think I need to be more specific. I ignore "SPEAKER_…" because then I can use the same shortcut to easily change speaker identification in transcripts.

(defvar sacha-substitute-save-changes "SPEAKER_"
  "Non-nil means save changes to `sacha-subed-common-edits'.
If this is a string, it is treated as a regular expression, and only
strings that do NOT match this regular expression will get saved.
If this is a function, call it with the target string. It should return
non-nil if the substitution should be saved.")

(defun sacha-substitute-save-common-edits (target sub count scope)
  "Keep track of changes so I can add them to `sacha-subed-common-edits'."
  (when (cond
         ((functionp sacha-substitute-save-changes)
          (funcall sacha-substitute-save-changes target))
         ((stringp sacha-substitute-save-changes)
          (not (string-match sacha-substitute-save-changes target)))
         (t
          sacha-substitute-save-changes))
    (customize-save-variable
     'sacha-subed-common-edits
     (cons (list sub target)
           sacha-subed-common-edits))))
(use-package substitute
:bind ("C-;" . substitute-target-in-buffer)
      :config
      (setq substitute-fixed-letter-case t)
      (add-hook 'substitute-post-replace-functions #'substitute-report-operation)
      (add-hook 'substitute-post-replace-functions #'sacha-substitute-save-common-edits))

customize-save-variable is in charge of saving the changes after I replace something with susbtitute.el. If I want to remove or edit entries, I can use M-x customize-variable to change sacha-subed-common-edits.

4. Correcting the errors

Then I have some functions that make the changes automatically or interactively.

;;;###autoload
(defun sacha-subed-fix-common-errors ()
  (interactive )
  (let (done entry correction)
    (while (and
            (not done)
            (setq entry (sacha-subed-find-next-fix-point)))
      (setq correction (if (listp entry) (car entry) entry))
      (if (let ((case-fold-search nil))
            (looking-at (regexp-quote correction)))
          (forward-word 1)
        (if (called-interactively-p 'any)
            (let* ((c (read-char (format "%s (yn.): " correction))))
              (cond
               ((= c ?y) (replace-match correction t t))
               ((= c ?n) (goto-char (match-end 0)))
               ((= c ?j) (subed-mpv-jump-to-current-subtitle))
               ((= c ?.) (setq done t))))
          (replace-match correction t t))))))

;;;###autoload
(defun sacha-subed-fix-common-errors-from-start ()
  "Change common errors in this buffer."
  (interactive)
  (goto-char (point-min))
  (sacha-subed-fix-common-errors))

;;;###autoload
(defun sacha-subed-fix-common-errors-in-text (text)
  "Change common errors in TEXT."
  (interactive)
  (with-temp-buffer
    (insert text)
    (goto-char (point-min))
    (sacha-subed-fix-common-errors)
    (buffer-string)))

;;;###autoload
(defun sacha-subed-find-next-fix-point ()
  (when (re-search-forward
         (format "\\_<\\(%s\\)\\_>"
                 (downcase
                  (string-join
                   (seq-mapcat
                    (lambda (o)
                      (if (listp o)
                          (if (string= (car o) "") (cdr o) o)
                        (list o)))
                    sacha-subed-common-edits)
                   "\\|")))
         nil t)
    (goto-char (match-beginning 0))
    (seq-find
     (lambda (o)
       (if (listp o)
           (seq-find (lambda (s)
                       (save-match-data
                         (string-match
                          (format "\\_<%s\\>" (downcase s))
                          (downcase (match-string 0))))) o)
         (string= (downcase o) (downcase (match-string 0)))))
     sacha-subed-common-edits)))

;;;###autoload
(defun sacha-subed-fix-common-error ()
  (interactive)
  (let ((entry (sacha-subed-find-next-fix-point)))
    (replace-match (if (listp entry) (car entry) entry) t t)))

Then I can call sacha-subedf-fix-common-errors-in-text from my whisper-insert-text-at-point functions, and sacha-subed-fix-common-errors-from-start from sacha-stream-prepare-transcript-for-editing.

5. Other ways to define the correction

Here's another function to define a correction if you don't want to use substitute.el.

;;;###autoload
(defun sacha-subed-add-common-edit (beg end replacement)
  "Add this word to the misrecognized words."
  (interactive
   (let ((beg (if (region-active-p) (min (point) (mark))
                (skip-syntax-backward "w")
                (point)))
         (end (if (region-active-p) (max (point) (mark))
                (save-excursion (forward-word 1) (point)))))
     (list beg end
           (completing-read
            (format "Replacement (%s): " (buffer-substring beg end))
            (mapcar (lambda (o) (if (stringp o) o (car o))) sacha-subed-common-edits)))))
  (customize-set-variable
   'sacha-subed-common-edits
   (cond
    ((member replacement sacha-subed-common-edits)
     (cons (list replacement (buffer-substring-no-properties beg end))
           (delete replacement sacha-subed-common-edits)))
    ((assoc replacement sacha-subed-common-edits)
     (setcdr (assoc replacement sacha-subed-common-edits)
             (append (list replacement) (cdr (assoc replacement sacha-subed-common-edits))))
     sacha-subed-common-edits)
    (t
     (push (list replacement (buffer-substring-no-properties beg end))
           sacha-subed-common-edits))))
  (delete-region beg end)
  (insert replacement))

At some point, I really should abstract this out to its own package, because it's just so useful. Other people have actually managed to get it to work, which is always a nice milestone. Anyway, here it is, in case it's helpful for you too!

This is part of my EmacsConfiguration.
View Org source for this post

EmacsConf: recording and re-recording introductions

| emacs, emacsconf, subed

I record brief introductions for all the EmacsConf talks so that they can be played automatically. That way, hosts don't have to worry about pronunciations on air, and there's one less changeover that might introduce technical issues. We can cut to the next talk a bit abruptly because everything runs off a crontab-powered schedule to keep things running on time on multiple tracks, so it helps to have a little transition between Q&A and the next talk. It's also nice having some kind of pronunciation reference so that when people discuss the talks or even just think about them with their internal monologues, they might have a better sense of how to say the speakers' names. We ask speakers to say their names at the beginning of their presentation, but people don't often include their last names, so the intro gets that consistently. The intro videos are available on the talk pages after the conference, and I've occasionally used them to remember how someone's name is pronounced.

Here's an example intro from EmacsConf 2025:

Here's my process for preparing those intros with Emacs.

First, I create all the intro slides with LaTeX and TikZ using the function emacsconf-stream-generate-in-between-pages from emacsconf-stream.el. This year, the template I'm using is _template.tex and the background image is _template_bg.pdf. I used to use an SVG and just replace the elements within it (template.svg, emacsconf-stream-generate-in-between-page-svg). This year, some of the talk titles are very long and SVG doesn't have widespread support for wrapping. LaTeX handles wrapping and positioning beautifully. This even allows me to have ligatures like the "ff" in Jeff Trull's name. I noticed those ligatures disappeared when I used Inkscape to convert to PNG, so I needed this command instead: inkscape --pdf-poppler --export-type=png -w 1280 -h 720 --export-background-opacity=0 --export-text-to-path

This is the function that generates the individual intro slide:

emacsconf-stream-generate-in-between-page: Use LaTeX to generate the intro slide for TALK based on assets/in-between/_template.tex.
(defun emacsconf-stream-generate-in-between-page (talk &optional prev info force)
  "Use LaTeX to generate the intro slide for TALK based on assets/in-between/_template.tex."
  (interactive (list (emacsconf-complete-talk-info)))
  (let* ((prev (or prev (emacsconf-previous-talk talk info)))
         (dir (expand-file-name "in-between" emacsconf-stream-asset-dir))
         (template
          (with-temp-buffer
            (insert-file-contents
             (expand-file-name "_template.tex" dir))
            (buffer-string)))
         (default-directory dir))
    (write-region
     (emacsconf-replace-plist-in-string
      (list
       :current-title
       (or (plist-get talk :title) "")
       :current-speakers
       (or (plist-get talk :speakers) "")
       :current-details
       (format "%s\\\\\n%s"
               (or (plist-get talk :absolute-url) "")
               (pcase (plist-get talk :q-and-a)
                 ((rx "live") "Live Q\\&A after talk")
                 ((rx "pad") "Etherpad")
                 ((rx "IRC") "IRC Q\\&A after talk")
                 (_ "")))
       :previous-title
       (or (plist-get prev :title) "")
       :conf-name emacsconf-name
       :conf-year emacsconf-year
       :previous-speakers
       (or (plist-get prev :speakers) "")
       :previous-details
       (format "%s\\\\\n%s"
               (or (plist-get prev :absolute-url) "")
               (pcase (plist-get prev :q-and-a)
                 ((rx "live") "Live Q\\&A after talk")
                 ((rx "pad") "Etherpad")
                 ((rx "IRC") "IRC Q\\&A after talk")
                 (_ ""))))
      template)
     nil
     (expand-file-name (concat (plist-get talk :slug) ".tex") dir))
    (shell-command
     (format "lualatex -shell-escape %s && inkscape --pdf-poppler --export-type=png -w 1280 -h 720 --export-background-opacity=0 --export-text-to-path %s"
             (expand-file-name (concat (plist-get talk :slug) ".tex")
                               dir)
             (expand-file-name (concat (plist-get talk :slug) ".pdf")
                               dir)))))

and here's an example slide it creates:

listen.png

Once I had the intro slides, I prepared my script. I called emacsconf-subed-intro-subtitles from emacsconf-subed.el to create a VTT captions file that starts like this:

WEBVTT


NOTE
#+OUTPUT: emacsconf-2026-sat-open--saturday-opening-remarks--sacha-chua--intro.webm
[[file:/home/sacha/proj/emacsconf/2026/assets/in-between/sat-open.png]]

00:00:00.000 --> 00:00:00.000
Next, we have "Saturday opening remarks",
by Sacha Chua.
You can ask questions via Etherpad.

NOTE
#+OUTPUT: emacsconf-2026-planning--the-emacs-planning-habits-of-a-questionably-effective-person-my-40year-journey-of-planning-with-emacs-org-mode-paper-journals-etc--george-jones--intro.webm
[[file:/home/sacha/proj/emacsconf/2026/assets/in-between/planning.png]]

00:00:00.000 --> 00:00:00.000
Next, we have "The Emacs Planning Habits of a Questionably Effective Person: My 40-year journey of planning with Emacs, Org Mode, paper journals, etc.",
by George Jones.
You can ask questions via web conference by joining from the talk page
or ask questions through Etherpad or IRC.

The text is based on the Org entry properties for each talk in our conf.org file. It used subed-record directives to define the output files and the visuals.

Then I used subed-record to start recording each segment. I pressed <left> (subed-record-retry) to re-record a segment as many times as I needed to. This adds or updates an #+AUDIO directive that points to the current recording and it also updates the timestamps. When I was satisfied, I pressed <right> (subed-record-accept-segment) to update the ending timestamp and move on to the next segment to record. Whenever I needed to take a break from recording, I used RET (subed-record-accept-and-stop) to accept the last segment and stop. After recording, I used subed-waveform-show-all to see the waveforms for each segment. I left- and right-clicked on the waveforms to refine the start and end timestamp, getting rid of the sound from the keyboard shortcuts, and I used subed-split-subtitle to split each long cue into the proper lines for the subtitles.

Here's the livestream where I worked on some of the intros.

After editing the audio this way, I used subed-record-compile-video (C-c C-c after subed-record-set-up) to create all the videos by using compile-media and FFmpeg. I could also regenerate just one or two videos by selecting the region and then using the same function..

Once the videos finished, I uploaded them to our password-protected backstage area, and emacsconf-publish-backstage-index added them to the page.

2026-11-12_09-25-45.png
Figure 1: Backstage links to intro

Then I used emacsconf-mail-intro-to-all to send emails to all the speakers with the links to the intros for review. Many speakers confirmed that their pronunciations were fine, and some replied with a recording of their name so that I could use it for reference. I added those in the comments so that I could replay them while recording with R (learn-lang-subed-record-play-current-reference) or learn-lang-subed-record-play-reference-and-current-subtitle. I also copied and pasted the relevant part of the caption file so that I could record different variations with subed-record. It's just text, after all, so it's easy to do all sorts of things the way that you would do them normally in Emacs. For example, here's what it looked like when I was editing the versions for Erik's name:

2026-11-12_14-48-14.png
Figure 2: Screenshot showing reference comments

Erik said option B sounds closest. It's not quite perfect, but it's closer than the pronunciation I started with. I might circle back around to this and try again sometime. =) Anyway, to use option B in the final video, I can just delete the cues for the other versions and remove the part where I said option B. Then I can select that part of the subtitles and compile just his video.

2026-11-12_21-14-47.png
Figure 3: After selecting the audio for Erik's intro

This makes it easy to update the intros whenever something changes. For example, if a speaker turns out to be available during the conference for a live Q&A session, I can update the Org entry for their talk (set :Q_AND_A: live), regenerate the intro slide, and re-record the Q&A explanation or even copy-and-paste one from a different intro. They can also change their talk title and that's totally okay. Yay Emacs!

View Org source for this post

subed.el and quoting snippets of YouTube videos from the auto captions

| emacs, audio, subed

I'm preparing for a conversation with linkarzu. It would be fun to quote snippets from some of the other videos he has. I like the way he does a lot of reaction videos that build on what people have shared. He tends to listen to things at 1.25 or 1.5x speed. I'm not sure if I have the patience even for that, so it'd be nice to be able to just quickly skim the text. He also clips a lot of his own videos. It might be interesting to play around with my workflows for listening to snippets and clipping them.

I've grabbed YouTube captions and reformatted them before:

This time around, I want to get the VTT format so that I can possibly use them with subed-record to clip audio or video.

From a YouTube link, I want to run a single command that gets me a VTT file with that as the media source and with the captions. If there are any chapters in the description, it would be lovely to get them too. I can get them from the JSON, yay!

Now I can use M-x sacha-subed-youtube to open the VTT file, which is cached locally, and I can use M-x sacha-subed-youtube-region-as-quote after selecting a section. Well, actually, I have an Embark command s (for "subed") that I can run on a YouTube video link and a selected-mode shortcut for y that I can run when the region is selected. Results:

I Asked Prot If I Should Switch to Emacs

00:09:46: I think the value of Org is that it is in the context of Emacs, which can now do other things. It can be your email client. It can be your agenda. Of course, it can be your programming environment. All these sorts of things, like your RSS feed reader and so on. And in the context of all that, you also have Org. So for me, that's kind of the value. But otherwise, having Org elsewhere, it's great still, because the paradigm of Org, I think, is a portable paradigm.

Org Mode in Neovim Is Finally Here - Full org.nvim Demo

00:00:00: I think that I achieved like 100% of parity with the original Org Mode version on Emacs.

Code for subed + YouTube
(defvar sacha-subed-youtube-dir "~/proj/youtube-captions"
  "Directory with YouTube captions.")
(defvar sacha-subed-youtube-temp-dir "~/Downloads" "Snap installations need a workaround for permission.")
;;;###autoload
(defun sacha-subed-youtube (url)
  "Download the automatic subtitles or check my cache."
  (interactive "MURL: ")
  (let* ((id (sacha-org-yt-id url))
         (existing (car (directory-files sacha-subed-youtube-dir t
                                         (concat "^" (regexp-quote id) ".*\\.vtt\\'")))))
    (if existing
        (progn
          (find-file existing)
          (subed-mpv-play-from-url url))
      ;; Download
      (let ((directory (make-temp-file (expand-file-name "yt-dlp" sacha-subed-youtube-temp-dir) t))
            filename
            json
            match
            chapters
            subtitles)
        (with-current-buffer (get-buffer-create "*yt-dlp*")
          (let ((default-directory directory))
            (call-process
             "yt-dlp" nil t nil
             "--skip-download"
             "--write-info-json"
             "--sub-format"
             "vtt"
             "--write-subs"
             "--write-auto-subs"
             url)))
        (when (null (directory-files directory t "\\.json$"))
          (error "Could not get data."))
        (setq json (json-read-file (car (directory-files directory t "\\.json$"))))
        (setq chapters (alist-get 'chapters json))
        (setq filename (expand-file-name
                        (concat id " - " (alist-get 'title json) ".vtt")
                        sacha-subed-youtube-dir))
        (setq subtitles (subed-parse-file (car (directory-files
                                                directory t
                                                "\\.vtt$"))))
        (delete-directory directory t)
        ;; add the chapters as comments
        (mapc
         (lambda (sub)
           (when (and chapters
                      (>= (elt sub 1)
                          (* (alist-get 'start_time (car chapters)) 1000)))
             (setf (elt sub 4) (alist-get 'title (pop chapters)))))
         subtitles)
        (subed-create-file
         filename
         subtitles
         t)
        (find-file filename)
        (subed-mpv-play-from-url url)))))

(defun sacha-subed-youtube-id ()
  "Return the YouTube ID."
  (or (save-restriction
        (save-excursion
          (goto-char (point-min))
          (subed-forward-subtitle-text)
          (when (subed-record-get-directive "YOUTUBE_URL")
            (sacha-org-yt-id
             (subed-record-get-directive "YOUTUBE_URL")))))
      (car (split-string (file-name-base (buffer-file-name)) " "))))

;; Now we just need a quick way to copy a YouTube URL.
;;;###autoload
(defun sacha-subed-youtube-url (&optional start-msecs end-msecs)
  "Copy YouTube URL for the current timestamp."
  (interactive)
  (when-let*
      ((id (sacha-subed-youtube-id))
       (s
        (if end-msecs
            (format "https://youtu.be/%s?t=%d&end=%d"
                    id
                    (/ (or start-msecs (subed-subtitle-msecs-start))
                       1000)
                    (1+ (/ end-msecs
                           1000)))
          (format "https://youtu.be/%s?t=%d"
                    id
                    (/ (or start-msecs (subed-subtitle-msecs-start))
                       1000)))))
    (when (called-interactively-p 'any)
      (kill-new s)
      (message "%s" s))
    s))

;;;###autoload
(defun sacha-subed-youtube-play ()
  "Play this video from YouTube."
  (interactive)
  (when-let*
      ((id (sacha-subed-youtube-id))
       (s (concat "https://youtu.be/" id)))
    (when (string= subed-mpv-media-file s)
      (subed-mpv-play-from-url s))
    (subed-mpv-jump-to-current-subtitle)
    (subed-mpv-unpause)))

;;;###autoload
(defun sacha-subed-youtube-region-as-quote (beg end &optional label)
  "Format this as a quote."
  (interactive (list (region-beginning) (region-end) (when current-prefix-arg (read-string "Label: "))))
  (let* ((id (sacha-subed-youtube-id))
         (url (sacha-subed-youtube-url
               (save-excursion
                 (goto-char beg)
                 (subed-subtitle-msecs-start))
               (save-excursion
                 (goto-char end)
                 (subed-subtitle-msecs-stop))))
         (base (file-name-base (buffer-file-name)))
         (text (subed-subtitle-list-text (subed-subtitle-list beg end)))
         (s (format
             "%s\n#+begin_quote\n%s: %s\n#+end_quote\n"
             (org-link-make-string
              (concat "yt:" url)
              (or label
                  (and (string-match (format "^%s - \\(.+\\)" (regexp-quote id)) base)
                       (match-string 1 base))
                  (sacha-page-title url)))
             (org-link-make-string
              (concat "vtime:"
                      (subed-msecs-to-timestamp
                       (save-excursion
                         (goto-char beg)
                         (subed-subtitle-msecs-start))
                       t)))
             (with-temp-buffer
               (insert text)
               (let ((fill-column most-positive-fixnum))
                 (fill-region (point-min) (point-max))
                 (string-trim (buffer-string)))))))
      (when (called-interactively-p 'any)
        (kill-new s)
        (message "%s" s))
      s))

Some of this code hasn't been committed to subed yet, but I will commit it sometime this week.

My next steps might be to:

  • cache the video as a whole to make it easier to check the waveforms
  • extract the segment to a standalone video file so that it's easy for me to play back or include in another video
  • see if I can use my voice activity detection and semi-streaming speech recognition to get a VTT of my current OBS recording
This is part of my EmacsConfiguration.
View Org source for this post

Comparing pronunciation recordings across time

Posted: - Modified: | french, emacs, org, subed
  • : Added reconstructions from today and moved more of the code to sachac/learn-lang.
  • : Added updates from today.
  • : Added reference audio for the second set.
  • : I added pronunciation segments for the new set of tongue-twisters I got on Mar 13.
  • : I added a column for Feb 20, the first session with the sentences. I also added keyboard shortcuts (1..n) for playing the audio of the row that the mouse is on.

2026-02-20: First set: Maman peint un grand lapin blanc, etc.

My French tutor gave me a list of sentences to help me practise pronunciation.

I can fuzzy-match these with the word timing JSON from WhisperX, like this.

Extract all approximately matching phrases
(subed-record-extract-all-approximately-matching-phrases
   sentences
   "/home/sacha/sync/recordings/2026-02-20-raphael.json"
   "/home/sacha/proj/french/analysis/virelangues/2026-02-20-raphael-script.vtt")
Sentences
  • Maman peint un grand lapin blanc.
  • Un enfant intelligent mange lentement.
  • Le roi croit voir trois noix.
  • Le témoin voit le chemin loin.
  • Moins de foin au loin ce matin.
  • La laine beige sèche près du collège.
  • La croquette sèche dans l'assiette.
  • Elle mène son frère à l'hôtel.
  • Le verre vert est très clair.
  • Elle aimait manger et rêver.
  • Le jeu bleu me plaît peu.
  • Ce neveu veut un jeu.
  • Le feu bleu est dangereux.
  • Le beurre fond dans le cœur chaud.
  • Les fleurs de ma sœur sentent bon.
  • Le hibou sait où il va.
  • L'homme fort mord la pomme.
  • Le sombre col tombe.
  • L'auto saute au trottoir chaud.
  • Le château d'en haut est beau.
  • Le cœur seul pleure doucement.
  • Tu es sûr du futur ?
  • Trois très grands trains traversent trois trop grandes rues.
  • Je veux deux feux bleus, mais la reine préfère la laine beige.
  • Vincent prend un bain en chantant lentement.
  • La mule sûre court plus vite que le loup fou.
  • Luc a bu du jus sous le pont où coule la boue.
  • Le frère de Robert prépare un rare rôti rouge.
  • La mule court autour du mur où hurle le loup.

Then I can use subed-record to manually tweak them, add notes, and so on. I end up with VTT files like 2026-03-06-raphael-script.vtt. I can assemble the snippets for a session into a single audio file, like this:

I wanted to compare my attempts over time, so I wrote some code to use Org Mode and subed-record to build a table with little audio players that I can use both within Emacs and in the exported HTML. This collects just the last attempts for each sentence during a number of my sessions (both with the tutor and on my own). The score is from the Microsoft Azure pronunciation assessment service. I'm not entirely sure about its validity yet, but I thought I'd add it for fun. * indicates where I've added some notes from my tutor, which should be available as a title attribute on hover. (Someday I'll figure out a mobile-friendly way to do that.)

Calling it with my sentences and files
(learn-lang-subed-record-summarize-segments
 sentences
 '(("/home/sacha/proj/french/analysis/virelangues/2026-02-20-raphael-script.vtt" . "Feb 20")
 ;("~/sync/recordings/processed/2026-02-20-raphael-tongue-twisters.vtt" . "Feb 20")
        ("~/sync/recordings/processed/2026-02-22-virelangues-single.vtt" . "Feb 22")
        ("~/proj/french/recordings/2026-02-26-virelangues-script.vtt" . "Feb 26")
        ("~/proj/french/recordings/2026-02-27-virelangues-script.vtt" . "Feb 27")
        ("~/proj/french/recordings/2026-03-03-virelangues.vtt" . "Mar 3")
        ("/home/sacha/sync/recordings/processed/2026-03-03-raphael-reference-script.vtt" . "Mar 3")
        ("~/proj/french/analysis/virelangues/2026-03-06-raphael-script.vtt" . "Mar 6")
        ("~/proj/french/analysis/virelangues/2026-03-12-virelangues-script.vtt" . "Mar 12"))
 "~/proj/french/analysis/virelangues/clip"
 #'learn-lang-subed-record-get-last-attempt
 )
Feb 20 Feb 22 Feb 26 Feb 27 Mar 3 Mar 3 Mar 6 Mar 12 Text
▶️ 63* ▶️ 96 ▶️ 95 ▶️ 94 ▶️ 83 ▶️ 83* ▶️ 81* ▶️ 88 Maman peint un grand lapin blanc.
▶️ 88* ▶️ 95 ▶️ 99 ▶️ 99 ▶️ 96 ▶️ 89* ▶️ 92* ▶️ 83 Un enfant intelligent mange lentement.
▶️ 84* ▶️ 97 ▶️ 97 ▶️ 96 ▶️ 94 ▶️ 95* ▶️ 98* ▶️ 99 Le roi croit voir trois noix.
▶️ 80* ▶️ 85 ▶️ 77 ▶️ 94 ▶️ 97   ▶️ 92* ▶️ 88 Le témoin voit le chemin loin.
▶️ 72* ▶️ 97 ▶️ 95 ▶️ 77 ▶️ 92   ▶️ 89* ▶️ 86 Moins de foin au loin ce matin.
▶️ 79* ▶️ 95 ▶️ 76 ▶️ 95 ▶️ 76 ▶️ 90* ▶️ 90* ▶️ 79 La laine beige sèche près du collège.
▶️ 67* ▶️ 99 ▶️ 85 ▶️ 81 ▶️ 85 ▶️ 99* ▶️ 97* ▶️ 97 La croquette sèche dans l'assiette.
▶️ 88* ▶️ 99 ▶️ 100 ▶️ 100 ▶️ 98 ▶️ 100* ▶️ 99* ▶️ 100 Elle mène son frère à l'hôtel.
▶️ 77* ▶️ 87 ▶️ 99 ▶️ 93 ▶️ 87   ▶️ 87* ▶️ 99 Le verre vert est très clair.
▶️ 100* ▶️ 94 ▶️ 100 ▶️ 99 ▶️ 99 ▶️ 99* ▶️ 100* ▶️ 100 Elle aimait manger et rêver.
▶️ 78* ▶️ 98 ▶️ 99 ▶️ 98 ▶️ 98 ▶️ 92*   ▶️ 88 Le jeu bleu me plaît peu.
▶️ 78* ▶️ 97 ▶️ 85 ▶️ 95 ▶️ 85     ▶️ 85 Ce neveu veut un jeu.
▶️ 73* ▶️ 95 ▶️ 95 ▶️ 96 ▶️ 97     ▶️ 100 Le feu bleu est dangereux.
▶️ 87* ▶️ 76 ▶️ 65 ▶️ 97 ▶️ 85 ▶️ 74* ▶️ 85* ▶️ 96 Le beurre fond dans le cœur chaud.
▶️ 84* ▶️ 43 ▶️ 85 ▶️ 79 ▶️ 75     ▶️ 98 Les fleurs de ma sœur sentent bon.
▶️ 70* ▶️ 86 ▶️ 79 ▶️ 76 ▶️ 87 ▶️ 84   ▶️ 98 Le hibou sait où il va.
▶️ 92* ▶️ 95 ▶️ 86 ▶️ 92 ▶️ 98 ▶️ 99*   ▶️ 94 L'homme fort mord la pomme.
▶️ 83* ▶️ 73 ▶️ 69 ▶️ 81 ▶️ 60 ▶️ 96*   ▶️ 81 Le sombre col tombe.
▶️ 39* ▶️ 49 ▶️ 69 ▶️ 56 ▶️ 69 ▶️ 96*   ▶️ 94 L'auto saute au trottoir chaud.
▶️ 82 ▶️ 84 ▶️ 85 ▶️ 98 ▶️ 94 ▶️ 96*   ▶️ 99 Le château d'en haut est beau.
▶️ 89 ▶️ 85 ▶️ 75 ▶️ 91 ▶️ 52 ▶️ 75* ▶️ 70* ▶️ 98 Le cœur seul pleure doucement.
▶️ 98*   ▶️ 99 ▶️ 99 ▶️ 95 ▶️ 93* ▶️ 97* ▶️ 99 Tu es sûr du futur ?
    ▶️ 97 ▶️ 93 ▶️ 92 ▶️ 85*   ▶️ 90 Trois très grands trains traversent trois trop grandes rues.
    ▶️ 94 ▶️ 85 ▶️ 97 ▶️ 82*   ▶️ 92 Je veux deux feux bleus, mais la reine préfère la laine beige.
    ▶️ 91 ▶️ 79 ▶️ 87 ▶️ 82*   ▶️ 94 Vincent prend un bain en chantant lentement.
    ▶️ 89 ▶️ 91 ▶️ 91 ▶️ 84*   ▶️ 92 La mule sûre court plus vite que le loup fou.
    ▶️ 91 ▶️ 93 ▶️ 93 ▶️ 92*   ▶️ 96 Luc a bu du jus sous le pont où coule la boue.
    ▶️ 88 ▶️ 71 ▶️ 94 ▶️ 86*   ▶️ 92 Le frère de Robert prépare un rare rôti rouge.
    ▶️ 81 ▶️ 84 ▶️ 88 ▶️ 67*   ▶️ 94 La mule court autour du mur où hurle le loup.

Pronunciation still feels a bit hit or miss. Sometimes I say a sentence and my tutor says "Oui," and then I say it again and he says "Non, non…" The /ʁ/ and /y/ sounds are hard.

I like seeing these compact links in an Org Mode table and being able to play them, thanks to my custom audio link type. It should be pretty easy to write a function that lets me use a keyboard shortcut to play the audio (maybe using the keys 1-9?) so that I can bounce between them for comparison.

If I screen-share from Google Chrome, I can share the tab with audio, so my tutor can listen to things at the same time. Could be fun to compare attempts so that I can try to hear the differences better. Hmm, actually, let's try adding keyboard shortcuts that let me use 1-8, n/p, and f/b to navigate and play audio. Mwahahaha! It works!

2026-03-14: Second set: Mon oncle peint un grand pont blanc, etc.

Update 2026-03-14: My tutor gave me a new set of tongue-twisters. When I'm working on my own, I find it helpful to loop over an audio reference with a bit of silence after it so that I can repeat what I've heard. I have several choices for reference audio:

  • I can generate an audio file using text-to-speech, like a local instance of Kokoro TTS, or a hosted service like Google Translate (via gtts-cli), ElevenLabs, or Microsoft Azure.
  • I can extract a recording of my tutor from one of my sessions.
  • I can extract a recording of myself from one of my tutoring sessions where my tutor said that the pronunciation is alright.

Here I stumble through the tongue-twisters. I've included reference audio from Kokoro, gtts, and ElevenLabs for comparison.

(my-subed-record-analyze-file-with-azure-and-references
 (subed-record-keep-last
  (subed-record-filter-skips
   (subed-parse-file
    "/home/sacha/proj/french/analysis/virelangues/2026-03-13-raphael-script.vtt")))
 "~/proj/french/analysis/virelangues-2026-03-13/2026-03-13-clip")
Gt Kk Az Me ID Comments All Acc Flu Comp Conf  
👂🏼 👂🏼 👂🏼 ▶️ 1 X: pont 93 99 90 100 86 Mon oncle peint un grand pont blanc. {pont}
👂🏼 👂🏼 👂🏼 ▶️ 2 C'est mieux 68 75 80 62 87 Un singe malin prend un bon raisin rond.
👂🏼 👂🏼 👂🏼 ▶️ 3 Ouais, c'est ça 83 94 78 91 89 Dans le vent du matin, mon chien sent un bon parfum.
👂🏼 👂🏼 👂🏼 ▶️ 4 ok 75 86 63 100 89 Le soin du roi consiste à joindre chaque coin du royaume.
👂🏼 👂🏼 👂🏼 ▶️ 5 Ouais, c'est ça, parfait 83 94 74 100 88 Dans un coin du bois, le roi voit trois points noirs.
👂🏼 👂🏼 👂🏼 ▶️ 6 Ouais, parfait 90 92 87 100 86 Le feu de ce vieux four chauffe peu.
👂🏼 👂🏼 👂🏼 ▶️ 7 Ouais 77 85 88 71 86 Deux peureux veulent un peu de feu.
👂🏼 👂🏼 👂🏼 ▶️ 8   77 78 75 83 85 Deux vieux bœufs veulent du beurre.
👂🏼 👂🏼 👂🏼 ▶️ 9 Ouais, parfait 92 94 89 100 89 Elle aimait marcher près de la rivière.
👂🏼 👂🏼 👂🏼 ▶️ 10 Ok, c'est bien 93 98 89 100 90 Je vais essayer de réparer la fenêtre.
👂🏼 👂🏼 👂🏼 ▶️ 11 Okay 83 87 76 100 89 Le bébé préfère le lait frais.
👂🏼 👂🏼 👂🏼 ▶️ 12   77 92 70 86 90 Charlotte cherche ses chaussures dans la chambre.
👂🏼 👂🏼 👂🏼 ▶️ 13 Okay 91 90 94 91 88 Un chasseur sachant chasser sans son chien est-il un bon chasseur ?
👂🏼 👂🏼 👂🏼 ▶️ 14 Ouais 91 88 92 100 91 Le journaliste voyage en janvier au Japon.
👂🏼 👂🏼 👂🏼 ▶️ 15 C'est bien (X: dans un) 91 88 94 100 88 Georges joue du jazz dans un grand bar. {dans un}
👂🏼 👂🏼 👂🏼 ▶️ 16 C'est bien 88 87 94 88 85 Un jeune joueur joue dans le grand gymnase.
👂🏼 👂🏼 👂🏼 ▶️ 17   95 94 96 100 91 Le compagnon du montagnard soigne un agneau.
👂🏼 👂🏼 👂🏼 ▶️ 18   85 88 84 86 89 La cigogne soigne l’agneau dans la campagne.
👂🏼 👂🏼 👂🏼 ▶️ 19 grenouille 71 80 68 75 86 La grenouille fouille les feuilles dans la broussaille.

And comparing clips over time:

(learn-lang-subed-record-summarize-segments
 (split-string (org-file-contents "~/proj/french/analysis/virelangues-2026-03-13/phrases.txt") "\n")
 '(("/home/sacha/proj/french/analysis/virelangues/2026-03-13-raphael-script.vtt" . "Mar 13")
   ("/home/sacha/proj/french/analysis/virelangues-2026-03-13/2026-03-20-raphael-script.vtt" . "Mar 20")
   ("/home/sacha/proj/french/analysis/virelangues-2026-03-13/2026-03-24-raphael-script.vtt" . "Mar 24")
   ("/home/sacha/proj/french/analysis/virelangues-2026-03-13/2026-03-27-script.vtt" . "Mar 27"))
 "~/proj/french/analysis/virelangues-2026-03-13/all-"
 #'learn-lang-subed-record-get-last-attempt)
Mar 13 Mar 20 Mar 24 Mar 27 Text
▶️ 93* ▶️ 89 ▶️ 71* ▶️ 88 Mon oncle peint un grand pont blanc.
▶️ 68* ▶️ 82* ▶️ 90* ▶️ 91 Un singe malin prend un bon raisin rond.
▶️ 83* ▶️ 89* ▶️ 93* ▶️ 95 Dans le vent du matin, mon chien sent un bon parfum.
▶️ 75* ▶️ 84* ▶️ 86* ▶️ 90 Le soin du roi consiste à joindre chaque coin du royaume.
▶️ 83* ▶️ 88* ▶️ 96 ▶️ 97 Dans un coin du bois, le roi voit trois points noirs.
▶️ 90* ▶️ 90* ▶️ 90* ▶️ 99 Le feu de ce vieux four chauffe peu.
▶️ 77* ▶️ 77* ▶️ 84* ▶️ 89 Deux peureux veulent un peu de feu.
▶️ 77 ▶️ 80* ▶️ 71* ▶️ 52 Deux vieux bœufs veulent du beurre.
▶️ 92* ▶️ 88* ▶️ 100* ▶️ 96 Elle aimait marcher près de la rivière.
▶️ 93* ▶️ 87* ▶️ 98* ▶️ 94 Je vais essayer de réparer la fenêtre.
▶️ 83* ▶️ 85* ▶️ 93* ▶️ 97 Le bébé préfère le lait frais.
▶️ 77 ▶️ 78* ▶️ 88* ▶️ 87 Charlotte cherche ses chaussures dans la chambre.
▶️ 91* ▶️ 92* ▶️ 97* ▶️ 92 Un chasseur sachant chasser sans son chien est-il un bon chasseur ?
▶️ 91* ▶️ 84* ▶️ 88* ▶️ 91 Le journaliste voyage en janvier au Japon.
▶️ 91*   ▶️ 79* ▶️ 95 Georges joue du jazz dans un grand bar.
▶️ 88* ▶️ 99* ▶️ 90* ▶️ 96 Un jeune joueur joue dans le grand gymnase.
▶️ 95 ▶️ 95 ▶️ 94* ▶️ 93 Le compagnon du montagnard soigne un agneau.
▶️ 85 ▶️ 63* ▶️ 86* ▶️ 100 La cigogne soigne l'agneau dans la campagne.
▶️ 71* ▶️ 64* ▶️ 79* ▶️ 91 La grenouille fouille les feuilles dans la broussaille.
  ▶️ 66* ▶️ 79* ▶️ 73 La vieille abeille travaille dans la broussaille.
  ▶️ 96* ▶️ 90* ▶️ 95 Le juge Jean juge justement les jolis bijoux de Julie.
    ▶️ 92* ▶️ 93 Ma compagne m'accompagne à la campagne avec une autre compagne.
      ▶️ 82 Une tortue têtue marche dessus sous une pluie continue.
      ▶️ 76 Une mule têtue pousse une roue lourde sur une rue boueuse.
      ▶️ 73 Trois gros rats gris grimpent dans trois grands greniers rugueux.
      ▶️ 84 Un professeur rigoureux corrige un rapport sur une erreur rare.

The code

Code for summarizing the segments
(defun my-subed-record-analyze-file-with-azure-and-references (subtitles prefix &optional always-create)
  (cons
   '("Gt" "Kk" "Az" "Me" "ID" "Comments" "All" "Acc" "Flu" "Comp" "Conf")
   (seq-map-indexed
    (lambda (sub i)
      (let ((sound-file (expand-file-name (format "%s-%02d.opus"
                                                  prefix
                                                  (1+ i))))
            (tts-services
             '(("gtts" . learn-lang-tts-gtts-say)
               ("kokoro" . learn-lang-tts-kokoro-fastapi-say)
               ("azure" . learn-lang-tts-azure-say)))
            tts-files
            (note (subed-record-get-directive "#+NOTE" (elt sub 4))))
        (when (or always-create (not (file-exists-p sound-file)))
          (subed-record-extract-audio-for-current-subtitle-to-file sound-file sub))
        (setq
         tts-files
         (mapcar
          (lambda (row)
            (let ((reference (format "%s-%s-%02d.opus" prefix (car row) (1+ i) )))
              (when (or always-create (not (file-exists-p reference)))
                (funcall (cdr row)
                         (subed-record-simplify (elt sub 3))
                         'sync
                         reference))
              (org-link-make-string
               (concat "audio:" reference "?icon=t&note=" (url-hexify-string (car row)))
               "👂🏼")))
          tts-services))
        (append
         tts-files
         (list
          (org-link-make-string
           (concat "audio:" sound-file "?icon=t"
                   (format "&source-start=%s" (elt sub 1))
                   (if (and note (not (string= note "")))
                       (format "&title=%s"
                               (url-hexify-string note))
                     ""))
           "▶️")
          (format "%d" (1+ i))
          (or note ""))
         (learn-lang-azure-subed-record-parse (elt sub 4))
         (list
          (elt sub 3)))))
    subtitles)))

Jumping to the source again:

(defun my-subed-record-org-clip-view-source ()
  (interactive)
  (let* ((params
          (url-parse-query-string
           (cdr
            (url-path-and-query
             (url-generic-parse-url
              (org-element-property :raw-link (org-element-context))))))))
    (find-file (car (alist-get "source-file" params nil nil #'string=)))
    (subed-jump-to-subtitle-id-at-msecs
     (string-to-number (car (alist-get "source-start" params nil nil #'string=))))))

I've moved the rest of the code to sachac/learn-lang on Codeberg.

View Org source for this post

Improving subed-vtt parsing; using dedicated windows in Emacs; training my intuition

| emacs, subed

While putting together some notes on how to use subed.el with auto-generated YouTube captions, I decided to get subed-word-data working with the Youtube VTT format. The sample file I downloaded from one of my YouTube videos had a cue whose text started with a blank line, so I ended up redoing the way subed-vtt.el parsed cues. Twice, actually. The first time, I changed it to handle multiple blocks in cue text (separated by blank lines). Then I came across this test suite for WebVTT parsing and found out that the timing line for a cue doesn't have to be preceded by a blank line, so then I needed to change the VTT parsing again.

Fortunately, I inherited a large Buttercup test suite from subed.el's original author. I've been adding to it over the years. As I learned more about how I wanted subed.el to behave, I added more cases. Then I worked on shifting the code to behave the way I wanted it to. At first, I didn't quite understand what I wanted the code to do, but as I pinned down more test cases, I was able to figure it out.

This was the first time I used toggle-window-dedicated (C-x w d) extensively. This function keeps the same buffer displayed in the window instead of letting Emacs Lisp functions replace it. First, I set up a large window for my subed-vtt.el. I split the other side into a smaller window for my test-subed-vtt.el, another window for a temporary VTT file, and a window for output from whatever command I'm running. I set most of the windows to dedicated except for my temporary output window. I also enabled winner-mode just in case I messed things up so that I could restore with winner-undo. Dedicating the windows meant I didn't have to keep fussing around with my windows and buffers to get things back to where I wanted them to be. I did use C-x o (other-window) a lot, so maybe it'll be worth getting the hang of ace-window.

2025-01-28_12-40-04.png
Figure 1: Dedicated windows for the code, the test file, and a VTT buffer for interactive testing; a spare window for other output

Sometimes I wanted to focus on one of those small windows. prot/window-single-toggle was helpful for maximizing a window and then returning to the previous configuration.

I mostly evaluated or edebugged my code and then used my-buttercup-run-dwim to run a suite in my test-subed-vtt.el. sp-backward-up-sexp and sp-narrow-to-sexp were also helpful for navigating the suites and focusing on whatever I was working on.

I'm looking forward to exploring the other test cases from that repository. It feels good to get better as a coder.

I just finished reading Mathematica: a Secret World of Imagination and Curiosity, by David Bessis. The idea of training your intuition echoed in my mind as I wrote test cases and changed the code. I started to look forward to the gaps between my understanding of the spec and my understanding of the test cases, and the gaps between the test cases and my implementation. It felt almost like a conversation. Sometimes it was hard to translate an idea into code. I felt myself getting muddled and turned around. Whenever I noticed that, I just had to back up and start from something I understood, figure out what I was uncertain about, and then go from there.

I like the way that subed.el gives me tools for thinking about text, times, and metadata together. That abstraction has been helpful for editing audio and making videos. The more solid I can make it, the easier it will be to imagine other things that use those ideas.

View org source for this post

Automatically correcting phrasing and misrecognized words in speech-to-text captions by using a script

| speechtotext, subed, emacs

I usually write my scripts with phrases that could be turned into the subtitles. I figured I might as well combine that information with the WhisperX transcripts which I use to cut out my false starts and oopses. To do that, I use the string-distance function, which calculates how similar strings are, based on the Levenshtein [distance] algorithm. If I take each line of the script and compare it with the list of words in the transcription, I can add one transcribed word at a time, until I find the number with the minimum distance from my current script phrase. This lets me approximately match strings despite misrecognized words. I use oopses to signal mistakes. When I detect those, I look for the previous script line that is closest to the words I restart with. I can then skip the previous lines automatically. When the script and the transcript are close, I can automatically correct the words. If not, I can use comments to easily compare them at that point. Even though I haven't optimized anything, it runs well enough for my short videos. With these subtitles as a base, I can get timestamps with subed-align and then there's just the matter of tweaking the times and adding the visuals.

Text from sketch

Matching a script with a transcript 2025-01-09-01

  • script
  • record on my phone
  • WhisperX transcript (with false starts and recognition errors)

My current implementation is totally unoptimized (n²) but it's fine for short videos.

Process:

  • While there are transcript words to process
    • Find the script line that has the minimum distance to the words left in the transcript. restart after oopses
  • Script
  • Transcript: min. distance between script phrase & transcript
  • Restarting after oops: find script phrase with minimum distance
  • Ex. script phrase: The Emacs text editor
  • Transcript: The Emax text editor is a…
  • Bar graph of distance decreasing, and then increasing again
  • Minimum distance
  • Oops?
    • N: Use transcript words, or diff > threshold?
      • Y: Add script words as comment
      • N: Correct minor errors
    • Y: Mark caption for skipping and look for the previous script line with minimum distance.

Result:

  • Untimed captions with comments
  • Aeneas
  • Timed captions for editing

This means I can edit a nicely-split, mostly-corrected file.

I've included the links to various files below so you can get a sense of how it works. Let's focus on an excerpt from the middle of my script file.

it runs well enough for my short videos.
With these subtitles as a base,
I can get timestamps with subed-align

When I call WhisperX with large-v2 as the model and --max_line_width 50 --segment_resolution chunk --max_line_count 1 as the options, it produces these captions corresponding to that part of the script.

01:25.087 --> 01:29.069
runs well enough for my short videos. With these subtitles

01:29.649 --> 01:32.431
as a base, I can get... Oops. With these subtitles as a base, I

01:33.939 --> 01:41.205
can get timestamps with subedeline, and then there's just

Running subed-word-data-use-script-file results in a VTT file containing this excerpt:

00:00:00.000 --> 00:00:00.000
it runs well enough for my short videos.

NOTE #+SKIP

00:00:00.000 --> 00:00:00.000
With these subtitles as a base,

NOTE #+SKIP

00:00:00.000 --> 00:00:00.000
I can get... Oops.

00:00:00.000 --> 00:00:00.000
With these subtitles as a base,

NOTE
#+TRANSCRIPT: I can get timestamps with subedeline,
#+DISTANCE: 0.14

00:00:00.000 --> 00:00:00.000
I can get timestamps with subed-align

There are no timestamps yet, but subed-align can add them. Because subed-align uses the Aeneas forced alignment tool to figure out timestamps by lining up waveforms for speech-synthesized text with the recorded audio, it's important to keep the false starts in the subtitle file. Once subed-align has filled in the timestamps and I've tweaked the timestamps by using the waveforms, I can use subed-record to create an audio file that omits the subtitles that have #+SKIP comments.

The code is available as subed-word-data-use-script-file in subed-word-data.el. I haven't released a new version of subed.el yet, but you can get it from the repository.

In addition to making my editing workflow a little more convenient, I think it might also come in handy for applying the segmentation from tools like sub-seg or lachesis to captions that might already have been edited by volunteers. (I got sub-seg working on my system, but I haven't figured out lachesis.) If I call subed-word-data-use-script-file with the universal prefix arg C-u, it should set keep-transcript-words to true and keep any corrections we've already made to the caption text while still approximately matching and using the other file's segments. Neatly-segmented captions might be more pleasant to read and may require less cognitive load.

There's probably some kind of fancy Python project that already does this kind of false start identification and script reconciliation. I just did it in Emacs Lisp because that was handy and because that way, I can make it part of subed. If you know of a more robust or full-featured approach, please let me know!

View org source for this post

#YayEmacs 9: Trimming/adding silences to get to a target; subed-record-sum-time

| audio, subed, yay-emacs, emacs, video

New in this video: subed-record-sum-time, #+PAD_LEFT and #+PAD_RIGHT

I like the constraints of a one-minute video, so I added a subed-record-sum-time command. That way, when I edit the video using Emacs, I can check how long the result will be. First, I split the subtitles, align it with the audio to fix the timestamps, and double check the times. Then I can skip my oopses. Sometimes WhisperX doesn't catch them, so I also look at waveforms and characters per second. I already talk quickly, so I'm not going to speed that up but I can trim the pauses in between phrases which is easy to do with waveforms. Sometimes, after reviewing a draft, I realize I need a little more time. If the original audio has some silence, I can just copy and paste it. If not, I can pad left or pad right to add some silence. I can try the flow of some sections and compile the video when I'm ready. Emacs can do almost anything. Yay Emacs!

You can watch this on YouTube, download the video, or download the audio.

Play by play:

  • I like the constraints of a one-minute video, so I added a subed-record-sum-time command. That way, when I edit the video using Emacs, I can check how long the result will be.
    • subed-record uses subtitles and directives in comments in a VTT subtitle file to edit audio and video. subed-record-sum-time calculates the resulting duration and displays it in the minibuffer.
  • First, I split the subtitles, align it with the audio to fix the timestamps, and double check the times.
    • I'm experimenting with an algorithmic way to combine the breaks from my script with the text from the transcript. subed-align calls the aeneas forced alignment tool to match up the text with the timestamps. I use subed-waveform-show-all to show all the waveforms.
  • Then I can skip my oopses.
    • Adding a NOTE #+SKIP comment before a subtitle makes subed-record-compile-video and subed-record-compile-flow skip that part of the audio.
  • Sometimes WhisperX doesn't catch them,
    • WhisperX sometimes doesn't transcribe my false starts if I repeat things quickly.
  • so I also look at waveforms
    • subed-waveform-show-all adds waveforms for all the subtitles. If I notice there's a pause or a repeated shape in the waveform, or if I listen and notice the repetition, I can confirm by middle-clicking on the waveform to sample part of it.
  • and characters per second.
    • Low characters per second is sometimes a sign that the timestamps are incorrect or there's a repetition that wasn't transcribed.
  • I already talk quickly, so I'm not going to speed that up
    • Also, I already sound like a chipmunk; mechanically speeding up my recording to fit in a certain time will make that worse =)
  • but I can trim the pauses in between phrases which is easy to do with waveforms.
    • left-click to set the start, right-click to set the stop. If I want to adjust the previous/next one at the same time, I would use shift-left-click or shift-right-click, but here I want to skip the gaps between phrases, so I adjust the current subtitle without making the previous/next one longer.
  • Sometimes, after reviewing a draft, I realize I need a little more time.
    • I can specify visuals like a video, animated GIF, or an image by adding a [[file:...]] link in the comment for a subtitle. That visual will be used until the next visual is specified in a comment on a different subtitle. subed-record-compile-video can automatically speed up video clips to fit in the time for the current audio segment, which is the set of subtitles before the next visual is defined. After I compile and review the video, sometimes I notice that something goes by too quickly.
  • If the original audio has some silence, I can just copy and paste it.
    • This can sometimes feel more natural than adding in complete silence.
  • If not, I can pad left or pad right to add some silence.
    • I added a new feature so that I could specify something like #+PAD_RIGHT: 1.5 in a comment to add 1.5 seconds of silence after the audio specified by that subtitle.
  • I can try the flow of some sections
    • I can select a region and then use M-x subed-record-compile-try-flow to play the audio or C-u M-x subed-record-compile-try-flow to play the audio+video for that region.
  • and compile the video when I'm ready.
    • subed-record-compile-video compiles the video to the file specified in #+OUTPUT: filename. ffmpeg is very arcane, so I'm glad I can simplify my use of it with Emacs Lisp.
  • Emacs can do almost anything. Yay Emacs!
    • Non-linear audio and video editing is actually pretty fun in a text editor, especially when I can just use M-x vundo to navigate my undo history.

Links:

Related:

View org source for this post