Grabbing the Youtube auto-generated captions is pretty useful when making Emacs News

| emacs

I’ve been adding Emacs-related videos to my public Emacs News playlist to make it easier to include them when I put together Emacs News every week. I still haven’t had much time to watch things, though. But the code I wrote to convert captions into a table so that they could be used to make notes after a meetup presentation turned out to be handy for Emacs News as well.

Screenshot_20210408_221732.png

Figure 1: With a bit of clicking, Youtube can display translated subtitles and a transcript on the side. I haven’t figured out how to get the transcript translated on Youtube yet.

Screenshot_20210408_221732.png

Figure 2: My Org buffer displays the auto-translated captions, making things easy to skim through.

Then I can jump to sections I’m particularly curious about. Neat!

View or add comments

2021-04-05 Emacs news

| emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, planet.emacslife.com, YouTube, the Emacs NEWS file and emacs-devel.

View or add comments

Monthly review: March 2021

| monthly, review

Lots of coding again this month!

  • Emacs News: I wrote some code to schedule announcements on IRC and Twitter, and I pulled the other meetups’ iCal feeds in automatically.
  • Streaming: I tried streaming again, but I think OBS was taking up too much CPU and it made my computer a little too unresponsive. I’ll try streaming from OBS to Twitch instead of using ffmpeg to multicast next time.
  • Captions: I wrote some code to use word-level timing from Google’s video transcripts when splitting subtitles. I experimented with redirecting my automatic caption output into Emacs, using it to dictate a few sentences.
  • Video processing: I split the BigBlueButton video based on XML, writing some Emacs Lisp code to generate title clips with LaTeX and make the FFMPEG commands to cut by keyframes when possible. I split out audio into a separate track for smoother playback.
  • Publishing: I added the ability to expand all, collapse all, and toggle visibility of headings in my exported HTML. I added night mode to my blog, and I removed the search form and sidebar.
  • Other Emacs improvements: I added preview to my consult function for reading a sketch filename. I added the ability to set the category and add other text to my journal from Emacs.
  • Drawing:
    • I drew a lot during A-‘s classes. I practised sketching plants following “Illustration School: Let’s Draw Plants and Small Creatures.”
    • I tried sketching in both Concepts and Procreate. They’re both nice. I modified my sketch viewer to handle SVGs. I figured out how to switch colours on the SVG I exported from Concepts so that it could respect dark mode. I also changed my stylesheet.
    • I wrote some Emacs Lisp code to extract paths or groups to individual SVGs in preparation for updating my font.
  • Other:
    • I sewed some long dresses and a bonnet for A-. She wears them often. I also sewed a pair of pajama pants for myself.
    • I ordered the Georgi chording keyboard. I want to see if I can get the hang of stenography for captioning, writing, and coding.

Blog posts

Sketches

Time

Category Previous month % This month % Diff % h/wk Diff h/wk
Sleep 30.1 34.6 4.4 64.2 7.4
Business 0.7 1.8 1.1 3.3 1.8
Discretionary – Family 0.0 0.2 0.2 0.3 0.3
Discretionary – Play 0.5 0.6 0.1 1.1 0.2
Discretionary – Social 0.1 0.0 -0.1 0.0 -0.1
Unpaid work 3.6 3.4 -0.2 6.4 -0.3
A- 45.9 44.4 -1.5 82.6 -2.5
Personal 6.2 4.6 -1.5 8.6 -2.6
Discretionary – Productive 12.9 10.4 -2.5 19.3 -4.2
View or add comments

Weekly review: Week ending April 2, 2021

| review, weekly
  • I converted A-‘s old dress and skirt into a floor-length dress.
  • I sketched a few more plants and animals from “Illustration School: Let’s Draw Plants and Small Animals.”
  • I dusted off my font-making workflow and started to figure out how to run things again. I was able to load the glyphs I drew in Concepts and kern them.
  • I wrote some Emacs Lisp code to extract paths or groups to individual SVGs in preparation for updating my font.
  • I attended the Emacs SF meetup. I also sorted out my announcement code.
  • I started playing around with Lispy. I used it when writing something to convert Youtube captions into an Org table.

Blog posts

Sketches

Time

Category The other week % Last week % Diff % h/wk Diff h/wk
Business 0.0 4.7 4.7 7.8 7.8
Sleep 32.0 33.3 1.2 55.9 2.1
Personal 4.2 5.4 1.2 9.1 2.0
Unpaid work 3.2 3.8 0.6 6.3 1.0
Discretionary – Family 0.2 0.6 0.4 1.0 0.7
Discretionary – Play 1.2 0.0 -1.2 0.0 -2.0
Discretionary – Productive 10.9 8.9 -2.0 15.0 -3.4
A- 48.3 43.4 -4.9 72.9 -8.2
View or add comments

Org Mode: Insert YouTube video with separate captions

| emacs

I’m playing around with some ideas for making it easier to post a video with its captions on a webpage or in an Org file so that it’s easier to skim or search.

This requires the youtube-dl command. I’m also learning how to use dash.el‘s threading macro, so you’ll need to install that as well if you want to run it.

(require 'dash)

(defun my/msecs-to-timestamp (msecs)
  "Convert MSECS to string in the format HH:MM:SS.MS."
  (concat (format-seconds "%02h:%02m:%02s" (/ msecs 1000))
          "." (format "%03d" (mod msecs 1000))))

(defun my/org-insert-youtube-video-with-transcript (url)
  (interactive "MURL: ")
  (let* ((id (if (string-match "v=\\([^&]+\\)" url) (match-string 1 url) url))
         (temp-file (make-temp-name "org-youtube-"))
         (temp-file-name (concat temp-file ".en.srv1"))
         data)
    (when (and (call-process "youtube-dl" nil nil nil
                             "--write-sub" "--write-auto-sub"  "--no-warnings" "--sub-lang" "en" "--skip-download" "--sub-format" "srv1"
                             "-o" temp-file
                             (format "https://youtube.com/watch?v=%s" id))
               (file-exists-p temp-file-name))
      (insert
       (format "#+begin_export html
<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/%s\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>\n#+end_export\n" id)
       "\n"
       (mapconcat (lambda (o)
                    (format "| [[https://youtube.com/watch?v=%s&t=%ss][%s]] | %s |\n"
                            id
                            (dom-attr o 'start)
                            (my/msecs-to-timestamp (* 1000 (string-to-number (dom-attr o 'start))))
                            (->> (dom-text o)
                                 (replace-regexp-in-string "[ \n]+" " ")
                                 (replace-regexp-in-string "&#39;" "'")
                                 (replace-regexp-in-string "&quot;" "\""))))
                  (dom-by-tag (xml-parse-file temp-file-name) 'text)
                  ""))
      (delete-file temp-file-name))))

It makes an embedded Youtube video and a table with captions below it. The Org file doesn’t look too bad, either.

Screenshot_20210401_234956.png

I decided to stick to standard Org syntax so that I can read it in Emacs too. With the current implementation, clicking on the timestamps jumps to that position in the video, but on the Youtube website. I haven’t coded anything fancy like keeping the embedded video at a fixed position, controlling it from the clicks, or highlighting the current position. It’s a start, though!

Here’s the output of running it with my talk from the last EmacsConf.

00:00:00.000 I’m Sacha Chua, and welcome to EmacsConf 2020.
00:00:04.000 To kick things off, here are ten cool things
00:00:07.000 that people have been working on
00:00:08.000 since the conference last year.
00:00:10.000 If you want to follow the links
00:00:11.000 or if you’d like to add something I’ve missed,
00:00:14.000 add them to the collaborative pad
00:00:16.000 if you’re watching this live
00:00:17.000 or check out the EmacsConf wiki page for this talk.

… (omitted for brevity)

This is part of my Emacs configuration.
View or add comments

2021-03-29 Emacs news

| emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, planet.emacslife.com, YouTube, the Emacs NEWS file and emacs-devel.

View or add comments

Weekly review: Week ending March 26, 2021

| review, weekly
  • Emacs:
    • I added the ability to expand all, collapse all, and toggle visibility of headings in my exported HTML.
    • I learned how to use org-special-blocks’ defblock for Org special blocks.
    • I added a preview to my consult function for reading a sketch filename.
  • Other tech:
    • I removed the search form and sidebar from my blog. I added night mode.
    • It turns out my laptop has 8 GB of RAM. That might have something to do with the CPU load with OBS – maybe it’s swapping? I looked at the prices for 16GB RAM kits, but I might still want to upgrade my laptop in order to have more screen choices and CPU power.
    • I started looking into the GEDCOM export from Geni, and I noticed that it was incomplete. I may have to manually re-enter the ones that other people put in.
  • Gardening:
    • W- and I moved the garden cage to the deck. I planted peas, calendula, and radishes in the planter outside. I started a small pot of pumpkin seeds.
    • I made sliding doors based on the LEGO Technic idea book we borrowed from the library.
  • Drawing:
    • I tried sketching in both Concepts and Procreate. They’re both nice.
    • I practised sketching plants and insects following “Illustration School: Let’s Draw Plants and Small Creatures.”
    • I modified my sketch viewer to handle SVGs. I figured out how to sketch with a dark background and change the colours for posting.
  • I sewed two long dresses and a bonnet for A-. I also sewed a pair of pajama pants for myself.

Blog posts

Sketches

Time

Category The other week % Last week % Diff % h/wk Diff h/wk
A- 41.7 48.3 6.6 81.6 11.1
Discretionary – Play 0.0 1.2 1.2 2.0 2.0
Unpaid work 2.4 3.2 0.8 5.4 1.3
Discretionary – Family 0.0 0.2 0.2 0.3 0.3
Discretionary – Productive 11.6 10.9 -0.7 18.4 -1.2
Personal 5.6 4.2 -1.3 7.1 -2.2
Sleep 38.8 32.0 -6.7 54.1 -11.3
View or add comments