<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/assets/atom.xsl" type="text/xsl"?><feed
	xmlns="http://www.w3.org/2005/Atom"
	xmlns:thr="http://purl.org/syndication/thread/1.0"
	xml:lang="en-US"
	><title>Sacha Chua - category - speech-recognition</title>
	<subtitle>Emacs, sketches, and life</subtitle>
	<link rel="self" type="application/atom+xml" href="https://sachachua.com/blog/category/speech-recognition/feed/atom/index.xml" />
  <link rel="alternate" type="text/html" href="https://sachachua.com/blog/category/speech-recognition" />
  <id>https://sachachua.com/blog/category/speech-recognition/feed/atom/index.xml</id>
  <generator uri="https://11ty.dev">11ty</generator>
	<updated>2026-10-07T19:52:45Z</updated>
<entry>
		<title type="html">Des commandes vocales pour ajouter des tâches sur Emacs</title>
		<link rel="alternate" type="text/html" href="https://sachachua.com/blog/2026/10/des-commandes-vocales-sur-emacs-pour-ajouter-des-taches/"/>
		<author><name><![CDATA[Sacha Chua]]></name></author>
		<updated>2026-10-07T19:52:45Z</updated>
    <published>2026-10-07T19:52:45Z</published>
    <category term="emacs" />
<category term="org" />
<category term="speech" />
<category term="speech-recognition" />
<category term="french" />
		<id>https://sachachua.com/blog/2026/10/des-commandes-vocales-sur-emacs-pour-ajouter-des-taches/</id>
		<content type="html"><![CDATA[<p>
</p><div class="yt-video"><iframe width="456" height="315" title="YouTube video player" src="https://www.youtube-nocookie.com/embed/rGAXW9S4AiE?enablejsapi=1" frameborder="0" allowfullscreen=""></iframe><a href="https://youtu.be/rGAXW9S4AiE">Watch on YouTube</a></div>
<p></p>

<p>
Liens :
</p>

<ul class="org-ul">
<li><a href="https://sachachua.com/blog/2026/09/experimenting-with-orukeet-for-speech-recognition/">Orukeet</a> pour la reconnaissance vocale parce qu'il est assez rapide et assez précis.</li>
<li><a href="https://github.com/sachac/whisper.el/">sachac/whisper.el</a></li>
<li><a href="https://codeberg.org/sachac/speech-input">speech-input</a></li>
</ul>

<p>
</p><div class="full-transcript"><p></p><div class="transcript-heading"><span class="audio-time" data-start="0.000000">0:00</span> <strong>Introduction</strong></div><p></p><span class="audio-time caption" data-speaker="" data-start="0.000000" data-stop="3.047000">Je veux vous présenter ma petite expérience</span> <span class="audio-time caption" data-speaker="" data-start="3.047000" data-stop="4.879000">de la reconnaissance vocale</span> <span class="audio-time caption" data-speaker="" data-start="4.879000" data-stop="6.778000">pour dicter dans Emacs</span> <span class="audio-time caption" data-speaker="" data-start="6.778000" data-stop="8.477000">et pour les contrôler.</span> <span class="audio-time caption" data-speaker="" data-start="8.477000" data-stop="10.444000">J'utilise le modèle Orukeet</span> <span class="audio-time caption" data-speaker="" data-start="10.444000" data-stop="12.876000">pour la reconnaissance vocale parce qu'il est</span> <span class="audio-time caption" data-speaker="" data-start="12.876000" data-stop="15.415000">assez rapide et assez précis.</span> <span class="audio-time caption" data-speaker="" data-start="15.415000" data-stop="18.335000">Je l'intègre dans Emacs en utilisant</span> <span class="audio-time caption" data-speaker="" data-start="18.335000" data-stop="22.034000">mes bibliothèques sachac/whisper.el et speech-input.</span> <span class="audio-time caption" data-speaker="" data-start="22.034000" data-stop="24.427000">J'ai récemment créé des commandes vocales</span> <span class="audio-time caption" data-speaker="" data-start="24.427000" data-stop="28.273000">pour ajouter des éléments à ma liste de tâches.</span> <span class="audio-time caption" data-speaker="" data-start="28.273000" data-stop="31.326000">C'est étonnement utile parce que ça réduit</span> <span class="audio-time caption" data-speaker="" data-start="31.326000" data-stop="34.325000">la charge cognitive liée à la mémorisation</span> <span class="audio-time caption" data-speaker="" data-start="34.325000" data-stop="35.951000">des raccourcis clavier.</span> <span class="audio-time caption" data-speaker="" data-start="35.951000" data-stop="37.551000">Je vais vous montrer cela.</span> <p></p><div class="transcript-heading"><span class="audio-time" data-start="37.000000">0:37</span> <strong>Ajouter des tâches
</strong></div><p></p><a href="https://sachachua.com/blog/2026/10/des-commandes-vocales-sur-emacs-pour-ajouter-des-taches/2026-10-07_14-11-23-00-00-58-833.jpg"><img loading="lazy" target="_blank" src="https://sachachua.com/blog/2026/10/des-commandes-vocales-sur-emacs-pour-ajouter-des-taches/2026-10-07_14-11-23-00-00-58-833.jpg" alt="image from video " data-time=""></a><span class="audio-time caption" data-speaker="" data-start="37.551000" data-stop="40.124000">Je presse la touche zéro du pavé numérique</span> <span class="audio-time caption" data-speaker="" data-start="40.124000" data-stop="42.390000">avant et après avoir dit</span> <span class="audio-time caption" data-speaker="" data-start="42.390000" data-stop="46.422000">« Rappelle-moi demain de préparer</span> <span class="audio-time caption" data-speaker="" data-start="46.422000" data-stop="48.668000">une présentation pour Emacs Paris</span> <span class="audio-time caption" data-speaker="" data-start="48.668000" data-stop="58.108000">sur les commandes vocales. »</span> <span class="audio-time caption" data-speaker="" data-start="58.108000" data-stop="63.228000">La fonction crée une tâche dans ma boîte de réception.</span> <span class="audio-time caption" data-speaker="" data-start="63.228000" data-stop="66.428000">La tâche est planifiée pour demain.</span> <span class="audio-time caption" data-speaker="" data-start="66.428000" data-stop="67.621000">Il y a un lien</span> <span class="audio-time caption" data-speaker="" data-start="67.621000" data-stop="69.900000">vers l'enregistrement</span> <p></p><div class="transcript-heading"><span class="audio-time" data-start="69.000000">1:09</span> <strong>D'autres dates
</strong></div><p></p><a href="https://sachachua.com/blog/2026/10/des-commandes-vocales-sur-emacs-pour-ajouter-des-taches/2026-10-07_14-11-23-00-02-26-667.jpg"><img loading="lazy" target="_blank" src="https://sachachua.com/blog/2026/10/des-commandes-vocales-sur-emacs-pour-ajouter-des-taches/2026-10-07_14-11-23-00-02-26-667.jpg" alt="image from video " data-time=""></a><span class="audio-time caption" data-speaker="" data-start="69.900000" data-stop="73.494000">« Rappelez-moi demain de préparer une présentation</span> <span class="audio-time caption" data-speaker="" data-start="73.494000" data-stop="81.680000">pour Emacs Paris sur les commandes vocales »,</span> <span class="audio-time caption" data-speaker="" data-start="81.680000" data-stop="88.940000">la capture d'écran et</span> <span class="audio-time caption" data-speaker="" data-start="88.940000" data-stop="90.240000">le contexte de tâche.</span> <span class="audio-time caption" data-speaker="" data-start="90.240000" data-stop="93.294000">Ça m'aident si j'ai été mal comprise</span> <span class="audio-time caption" data-speaker="" data-start="93.294000" data-stop="96.239000">ou si j'ai besoin de contexte.</span> <span class="audio-time caption" data-speaker="" data-start="96.239000" data-stop="97.327000">De la même manière,</span> <span class="audio-time caption" data-speaker="" data-start="97.327000" data-stop="100.526000">je peux dire « Rappelle-moi la semaine prochaine</span> <span class="audio-time caption" data-speaker="" data-start="100.526000" data-stop="110.237000">de faire la paperasse pour l'école. »</span> <span class="audio-time caption" data-speaker="" data-start="110.237000" data-stop="112.444000">« Rappelle-moi aujourd'hui de créer</span> <span class="audio-time caption" data-speaker="" data-start="112.444000" data-stop="119.376000">une vidéo sur mes commandes vocales. »</span> <p></p><div class="transcript-heading"><span class="audio-time" data-start="119.000000">1:59</span> <strong>Basculer à une tâche
</strong></div><p></p><a href="https://sachachua.com/blog/2026/10/des-commandes-vocales-sur-emacs-pour-ajouter-des-taches/2026-10-07_14-11-23-00-02-45-867.jpg"><img loading="lazy" target="_blank" src="https://sachachua.com/blog/2026/10/des-commandes-vocales-sur-emacs-pour-ajouter-des-taches/2026-10-07_14-11-23-00-02-45-867.jpg" alt="image from video " data-time=""></a><span class="audio-time caption" data-speaker="" data-start="119.376000" data-stop="122.296000">Je peux aussi créer une tâche et déclencher</span> <span class="audio-time caption" data-speaker="" data-start="122.296000" data-stop="125.455000">le suivi du temps (ou clock in).</span> <span class="audio-time caption" data-speaker="" data-start="125.455000" data-stop="127.095000">Par exemple, je peux dire</span> <span class="audio-time caption" data-speaker="" data-start="127.095000" data-stop="135.474000">« Commence à implémenter la génération des questions. »</span> <p></p><div class="transcript-heading"><span class="audio-time" data-start="135.000000">2:15</span> <strong>Retrouver le fil de mes pensées
</strong></div><p></p><a href="https://sachachua.com/blog/2026/10/des-commandes-vocales-sur-emacs-pour-ajouter-des-taches/2026-10-07_14-11-23-00-03-07-000.jpg"><img loading="lazy" target="_blank" src="https://sachachua.com/blog/2026/10/des-commandes-vocales-sur-emacs-pour-ajouter-des-taches/2026-10-07_14-11-23-00-03-07-000.jpg" alt="image from video " data-time=""></a><span class="audio-time caption" data-speaker="" data-start="135.474000" data-stop="138.107000">Si je perds le fil de mes pensées :</span> <span class="audio-time caption" data-speaker="" data-start="138.107000" data-stop="142.307000">« j'en étais où ? »</span> <span class="audio-time caption" data-speaker="" data-start="142.307000" data-stop="147.227000">Ça m'affiche les tâches récentes.</span> <p></p><div class="transcript-heading"><span class="audio-time" data-start="147.000000">2:27</span> <strong>Je faisais quoi ?
</strong></div><p></p><a href="https://sachachua.com/blog/2026/10/des-commandes-vocales-sur-emacs-pour-ajouter-des-taches/2026-10-07_14-11-23-00-03-27-333.jpg"><img loading="lazy" target="_blank" src="https://sachachua.com/blog/2026/10/des-commandes-vocales-sur-emacs-pour-ajouter-des-taches/2026-10-07_14-11-23-00-03-27-333.jpg" alt="image from video " data-time=""></a><span class="audio-time caption" data-speaker="" data-start="147.227000" data-stop="150.747000">« Je faisais quoi ? »</span> <span class="audio-time caption" data-speaker="" data-start="150.747000" data-stop="158.846000">Ça bascule sur la tâche actuelle.</span> <span class="audio-time caption" data-speaker="" data-start="158.846000" data-stop="163.226000">Voilà des commandes vocales pour ajouter des tâches.</span></div>
<p></p>
<div><a href="https://sachachua.com/blog/2026/10/des-commandes-vocales-sur-emacs-pour-ajouter-des-taches/index.org">View Org source for this post</a></div><p>You can <a href="mailto:sacha@sachachua.com?subject=Comment%20on%20https%3A%2F%2Fsachachua.com%2Fblog%2F2026%2F10%2Fdes-commandes-vocales-sur-emacs-pour-ajouter-des-taches%2F&body=Name%20you%20want%20to%20be%20credited%20by%20(if%20any)%3A%20%0AMessage%3A%20%0ACan%20I%20share%20your%20comment%20so%20other%20people%20can%20learn%20from%20it%3F%20Yes%2FNo%0A">e-mail me at sacha@sachachua.com</a>.</p>]]></content>
		</entry><entry>
		<title type="html">Emacs Carnival Oct 2026: Exploring keys and voice input in Emacs</title>
		<link rel="alternate" type="text/html" href="https://sachachua.com/blog/2026/10/emacs-carnival-oct-2026-exploring-keys-and-voice-input-in-emacs/"/>
		<author><name><![CDATA[Sacha Chua]]></name></author>
		<updated>2026-10-07T12:18:31Z</updated>
    <published>2026-10-07T12:18:31Z</published>
    <category term="emacs" />
<category term="speech-recognition" />
<category term="speech" />
		<id>https://sachachua.com/blog/2026/10/emacs-carnival-oct-2026-exploring-keys-and-voice-input-in-emacs/</id>
		<content type="html"><![CDATA[<div class="sticky-toc" id="orgf14a149">
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="https://sachachua.com/blog/feed/atom/index.xml#emacs-carnival-exploring-keys-and-voice-input-in-emacs-making-more-use-of-the-keyboard">Making more use of the keyboard</a></li>
<li><a href="https://sachachua.com/blog/feed/atom/index.xml#emacs-carnival-exploring-keys-and-voice-input-in-emacs-some-reasons-why-i-m-curious-about-speech-recognition">Some reasons why I'm curious about speech recognition</a></li>
<li><a href="https://sachachua.com/blog/feed/atom/index.xml#emacs-carnival-exploring-keys-and-voice-input-in-emacs-quick-benefits-from-voice-commands">Quick benefits from voice commands</a></li>
<li><a href="https://sachachua.com/blog/feed/atom/index.xml#emacs-carnival-exploring-keys-and-voice-input-in-emacs-prior-work-on-voice-control-of-emacs-voicemacs-emacslisten">Prior work on voice control of Emacs: Voicemacs, Emacslisten</a></li>
<li><a href="https://sachachua.com/blog/feed/atom/index.xml#emacs-carnival-exploring-keys-and-voice-input-in-emacs-imagining-a-hybrid-approach-keyboard-voice-even-mouse-stylus">Imagining a hybrid approach: keyboard, voice, even mouse/stylus?</a></li>
</ul>
</div>

</div>
<div id="outline-container-emacs-carnival-exploring-keys-and-voice-input-in-emacs-making-more-use-of-the-keyboard" class="outline-3">
<h3 id="emacs-carnival-exploring-keys-and-voice-input-in-emacs-making-more-use-of-the-keyboard"><a href="https://sachachua.com/blog/feed/atom/index.xml#emacs-carnival-exploring-keys-and-voice-input-in-emacs-making-more-use-of-the-keyboard">Making more use of the keyboard</a></h3>
<div class="outline-text-3" id="text-emacs-carnival-exploring-keys-and-voice-input-in-emacs-making-more-use-of-the-keyboard">
<p>
October's Emacs Carnival theme "<a href="https://www.emacswiki.org/emacs/CarnivalOctober2026">Are keyboards and M-x here to stay?</a>" is a good nudge to think about the voice interface I've been experimenting with and where I want to take it.
</p>

<p>
<a href="https://chrismaiorana.com/m-x-magic/">Like Chris Maiorana</a>, I love the way Emacs's <code>M-x</code> (<code>execute-extended-command</code>) allows me to call any command by name.
It means that I can call commands or come up with my own commands without worrying about assigning them to keyboard shortcuts or making sense of where to place them in a hierarchical menu.
With flexible completion via the <a href="https://github.com/minad/vertico">vertico</a> and <a href="https://github.com/oantolin/orderless">orderless</a> packages, I don’t even need to type in the full name of the command or remember the words in the right order.
If I still can’t remember the command, it’s easy enough to use defalias to make my own nickname for it.
</p>


<figure id="orga9cf8e9">
<a href="https://sachachua.com/blog/2026/10/emacs-carnival-oct-2026-exploring-keys-and-voice-input-in-emacs/2026-10-06_11-04-07.png"><img src="https://sachachua.com/blog/2026/10/emacs-carnival-oct-2026-exploring-keys-and-voice-input-in-emacs/2026-10-06_11-04-07.png" alt="2026-10-06_11-04-07.png"></a>

<figcaption><span class="figure-number">Figure 1: </span>I can filter M-x to show just my custom commands</figcaption>
</figure>

<p>
I tend to limit keyboard shortcuts to only my most common commands.
Everything else is hard to practise enough so that it sticks in my muscle memory.
Even with <a href="https://github.com/minad/marginalia">marginalia</a> showing me keybindings when I use <code>M-x</code> and <a href="https://emacsredux.com/blog/2026/07/18/which-key-is-now-built-in/">which-key</a> showing me hints when I pause, it doesn’t sink in.
</p>


<figure id="orgc830000">
<a href="https://sachachua.com/blog/2026/10/emacs-carnival-oct-2026-exploring-keys-and-voice-input-in-emacs/2026-10-06_11-05-00.png"><img src="https://sachachua.com/blog/2026/10/emacs-carnival-oct-2026-exploring-keys-and-voice-input-in-emacs/2026-10-06_11-05-00.png" alt="2026-10-06_11-05-00.png"></a>

<figcaption><span class="figure-number">Figure 2: </span>Marginalia shows keybindings</figcaption>
</figure>

<p>
Maybe I could use <a href="https://github.com/federicotdn/key-quiz">key-quiz</a> to drill a small number of keyboard shortcuts I’m actively working on learning, or modify <code>help-quick-sections</code> to show me reminders when I use <code>C-h C-q</code> (<code>help-quick-toggle</code>).
</p>

<p>
Getting one keyboard shortcut to do the right thing in different
contexts is great because it means fewer shortcuts to memorize. Sometimes I can do that by binding the right functions to different mode maps with <code>bind-key</code>, like the way my <a href="https://sachachua.com/blog/2025/09/adding-org-mode-link-awesomeness-elsewhere-my-org-insert-link-dwim/">sacha-org-insert-link-dwim</a> uses the right link syntax in Markdown or OddMuse too.
I also like the context-sensitive keyboard shortcuts I get from <a href="https://github.com/oantolin/embark">Embark</a>.
I find myself using a handful of those regularly, and <code>C-.</code>
(<code>embark-act</code>) starts a bunch of shortcuts across different types of
things: <code>i</code> to insert, <code>w</code> to copy, and so on.
For example, I know <code>C-x C-f</code> (<code>find-file</code>) will let me select a file to open.
Instead of opening it, I can use <code>C-. i</code> to insert the filename into the buffer.
</p>

<p>
Simpler keyboard shortcuts help. I rarely use the numpad on my laptop keyboard, so those keys can be mapped to functions that don't need to be followed by lots of typing. For example, 0 is a large button. I use it to start and stop speech recognition. Actually, I bind f9 in Emacs to <code>sacha-whisper-run-at-point</code>, and I bind numpad-0 as a keyboard shortcut in KDE (my window manager) instead of just in Emacs so that it's available globally. I'm still on X11 instead of Wayland. The shell script <a href="https://sachachua.com/blog/2026/10/emacs-carnival-oct-2026-exploring-keys-and-voice-input-in-emacs/xdotool-emacs">xdotool-emacs</a> focuses Emacs briefly and sends the keys, and the shortcut is set to <code>/home/sacha/bin/xdotool-emacs key &#45;&#45;clearmodifiers F9</code>. I do that instead of using emacsclient because emacsclient starts a different buffer, and I might want to keep the context. My <a href="https://sachachua.com/dotemacs#multimedia-whisper">sacha-whisper-maybe-type</a> function detects if Emacs is not the focused application and types the text if it isn't, which means I can use it as keyboard input for oher applications while still taking advantage of the corrections and commands I've defined in Emacs. An easy-to-press global shortcut means I can use it from anywhere, even when my foreground app is the browser or another application.
</p>

<p>
An additional modifier opens up more possibilities for keyboard shortcuts near the regular typing position. My Windows key acts like a Super modifier. I've set it up as a one-shot modifier with Kanata so that I can either hold it down to access more shortcuts or tap it to treat it like a leader key.
</p>

<p>
There are quite a few commands for which neither M-x nor keyboard shortcuts feel like the right fit: things I want to do faster or more fluidly than M-x, but which I don't do often enough to memorize a good shortcut for. I've been experimenting a bit with voice input, and I really like it.
</p>
</div>
</div>
<div id="outline-container-emacs-carnival-exploring-keys-and-voice-input-in-emacs-some-reasons-why-i-m-curious-about-speech-recognition" class="outline-3">
<h3 id="emacs-carnival-exploring-keys-and-voice-input-in-emacs-some-reasons-why-i-m-curious-about-speech-recognition"><a href="https://sachachua.com/blog/feed/atom/index.xml#emacs-carnival-exploring-keys-and-voice-input-in-emacs-some-reasons-why-i-m-curious-about-speech-recognition">Some reasons why I'm curious about speech recognition</a></h3>
<div class="outline-text-3" id="text-emacs-carnival-exploring-keys-and-voice-input-in-emacs-some-reasons-why-i-m-curious-about-speech-recognition">
<ul class="org-ul">
<li>I could use more practice speaking, since I don't talk to a lot of people in real life.
<ul class="org-ul">
<li><b>English:</b> Videos and livestreams can be a way to share interesting things and start conversations. I want to organize my thoughts, improve my breathing, and reduce my stutters and false starts. That will make the audio more pleasant to listen to. Dictating to my computer gives me more practice. It also makes things easier to livestream if I can reuse my speech as input.</li>
<li><p>
<b>French:</b> I like challenging my brain and I want to help the kiddo learn it too. Improving my speaking will also make it easier for me to listen to myself and close the feedback loop. Maybe I can even use speech recognition to give me feedback and increase motivation while speaking, like <a href="https://sachachua.com/dotemacs#writing-and-editing-speech-recognition-reporting-speaking-stats-balance">keeping track of words or phrases I want to use</a>. When I use them in conversation, the buffer can cross them off the list, which lets me focus on the words remaining.
</p>

<figure id="org07b8286">
<img src="https://sachachua.com/blog/2026/10/using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time/2026-10-07_07-33-03.png" alt="2026-10-07_07-33-03.png">

<figcaption><span class="figure-number">Figure 3: </span>Screenshot showing balance and target words</figcaption>
</figure></li>
</ul></li>
<li>Dictation can capture ideas quickly, with more natural wording, especially since typing sometimes gets messed up on my computer.</li>
<li>Voice interfaces might let me reduce some kinds of task friction or work hands-free. For example, I like setting timers by voice on my phone while cooking. It might be interesting to be able to dictate a draft while knitting or hand-sewing.</li>
<li>Brain fog is something I will likely need to deal with. I got a preview of it thanks to the sleep deprivation of early parenting. I know that brain fog is probably going to happen around menopause, it will probably also be part of aging, and it's a common symptom of long COVID which I might still end up getting despite my precautions. I could get into an accident and hurt my hands. I like Emacs and I want to be able to keep using it even if cognitive or physical changes make it harder to remember or use lots of keyboard shortcuts. If I start playing around with this now, the capabilities and the habits will be there when I need it.</li>
<li>Other people are already dealing with those kinds of physical or cognitive constraints, so things I figure out might be useful for other people.</li>
<li>A global shortcut for voice notes and commands let me quickly dash off a reminder before I take off. I don't have to find Emacs and go through my Org capture templates.</li>
<li>It's fun. I like saying "Prepare for take-off" and having Emacs get ready for a spontaneous stream by updating YouTube using my current Org Mode subtree title and description. I like seeing if my dictionary of substitutions can fix the commonly misrecognized words. Saying "I command you to&hellip;" to get Emacs to do a M-x command is totally inefficient but also playful, and silly things stick in my brain better thanks to the mnemonic advantage of humor. My brain likes that kind of novelty.</li>
</ul>

<p>
For context, I use Linux on a Lenovo P52 laptop (manufactured 2018, 64 GB RAM but hardly any GPU), and I have an Android phone. I like writing regular text, Emacs Lisp, and some Python and JavaScript. I'm slowly starting to have more focused time now that the kiddo is in virtual school, although it's still broken up by recess and lunch. I will probably have an increasing amount of focused time over the next few years.
</p>
</div>
</div>
<div id="outline-container-emacs-carnival-exploring-keys-and-voice-input-in-emacs-quick-benefits-from-voice-commands" class="outline-3">
<h3 id="emacs-carnival-exploring-keys-and-voice-input-in-emacs-quick-benefits-from-voice-commands"><a href="https://sachachua.com/blog/feed/atom/index.xml#emacs-carnival-exploring-keys-and-voice-input-in-emacs-quick-benefits-from-voice-commands">Quick benefits from voice commands</a></h3>
<div class="outline-text-3" id="text-emacs-carnival-exploring-keys-and-voice-input-in-emacs-quick-benefits-from-voice-commands">
<p>
I love the way voice reduces context shifts. For example, some of my most-used voice commands are:
</p>

<ul class="org-ul">
<li><p>
remind me [today/tomorrow/next week/next month/someday] to&hellip;: capture and schedule the task; include an Org link and screenshot for context, and link to the audio recording in case the text was misrecognized
</p>


<figure id="org3080bba">
<a href="https://sachachua.com/blog/2026/10/emacs-carnival-oct-2026-exploring-keys-and-voice-input-in-emacs/2026-10-07_10-00-55.png"><img src="https://sachachua.com/blog/2026/10/emacs-carnival-oct-2026-exploring-keys-and-voice-input-in-emacs/2026-10-07_10-00-55.png" alt="2026-10-07_10-00-55.png"></a>

<figcaption><span class="figure-number">Figure 4: </span>Captured tasks have an audio recording, a screenshot, and a link</figcaption>
</figure></li>

<li>switch to&hellip;: capture the task and immediately clock into it</li>
<li>what was I doing?: jump to the current task</li>
<li><p>
where was I?: show recently-clocked tasks
</p>

<figure id="orgb00fc87">
<a href="https://sachachua.com/blog/2026/10/emacs-carnival-oct-2026-exploring-keys-and-voice-input-in-emacs/2026-10-07_10-02-00.png"><img src="https://sachachua.com/blog/2026/10/emacs-carnival-oct-2026-exploring-keys-and-voice-input-in-emacs/2026-10-07_10-02-00.png" alt="2026-10-07_10-02-00.png"></a>

<figcaption><span class="figure-number">Figure 5: </span>This is the same as C-u M-x org-clock-goto</figcaption>
</figure></li>
</ul>

<p>
I don't have to think about which keys I've configured in <code>org-capture-templates</code>. I just use a natural phrase.
</p>

<p>
I've defined "open &hellip;" to open things from my <a href="https://sachachua.com/dotemacs/index.html#org-bookmarks">bookmarked links stored in an Org file</a>. Because my numpad-0 keybinding works from anywhere, I can even use it to open sites or capture notes while looking at my browser.
</p>

<p>
Because Emacs can interact with lots of other applications, I can even experiment with controlling those applications by voice. For example, I use obs-websocket.el to control OBS for streaming or recording a video. Using "Let's go live" and "Over and out" to start or stop streaming or "Start recording" and "Stop recording" to manage the recording means I can do that without needing to find the right window. I stream with a 10-second delay so that there's a little bit of time to catch any private information that's been accidentally shared on the screen. My new "panic" command lets me discard that delay and interrupt the stream by using an OBS keyboard shortcut to kill the stream immediately, even if I'm probably not going to remember that exact keyboard shortcut when I'm stressed. It should be a little easier to remember that than a keyboard shortcut I hardly ever use or a menu item that is a really small target (and my Emacs might not even be my foreground app).
</p>

<p>
For regular dictation, I'm experimenting with having it automatically place each sentence on a new line or list item. This makes it easy to reorganize in Org. I can refill it into a paragraph when I'm done.
</p>

<p>
I still have to deal with the limits of my memory, of course.
I have a "what can I say" command that opens up an Org file with my notes. I keep this as a manual note instead of just dumping the contents of my <code>sacha-whisper-commands</code> variable so that I can prioritize the things I'm trying to build as habits.
</p>

<p>
<a href="https://sachachua.com/dotemacs#writing-and-editing-speech-recognition-slowly-building-speech-based-commands-for-emacs">Here's the part of my config that sets up some speech commands</a>.
</p>

<p>
I might want more complex grammar someday for things that regular expressions can't easily handle.
That's something other projects have done a good job of figuring out.
</p>
</div>
</div>
<div id="outline-container-emacs-carnival-exploring-keys-and-voice-input-in-emacs-prior-work-on-voice-control-of-emacs-voicemacs-emacslisten" class="outline-3">
<h3 id="emacs-carnival-exploring-keys-and-voice-input-in-emacs-prior-work-on-voice-control-of-emacs-voicemacs-emacslisten"><a href="https://sachachua.com/blog/feed/atom/index.xml#emacs-carnival-exploring-keys-and-voice-input-in-emacs-prior-work-on-voice-control-of-emacs-voicemacs-emacslisten">Prior work on voice control of Emacs: Voicemacs, Emacslisten</a></h3>
<div class="outline-text-3" id="text-emacs-carnival-exploring-keys-and-voice-input-in-emacs-prior-work-on-voice-control-of-emacs-voicemacs-emacslisten">
<p>
There's been a lot of good work on voice input over the years, especially since a number of Emacs users have a hard time with or would like to avoid repetitive stress injury. In addition to the innumerable projects that let you use Whisper or similar speech recognition engines to dictate prose, there are also a few projects that use a constrained vocabulary to more reliably control Emacs. Two projects in this area are based on the <a href="https://talonvoice.com/">Talon</a> voice control system: <a href="https://github.com/jcaw/voicemacs">Voicemacs</a> and <a href="https://emacslisten.org/">Emacslisten</a>.
</p>

<ul class="org-ul">
<li>The <a href="https://github.com/talonhub/community">Talon community hub</a> defines some Emacs commands. I think it simulates keyboard input and assumes that you have <a href="https://github.com/lewang/flx">flx</a> or some other fuzzy completion matching so that input like <code>M-x t-d-on-e</code> runs <code>toggle-debug-on-error</code>, as defined in <a href="https://github.com/talonhub/community/blob/main/apps/emacs/emacs_commands.csv">community/apps/emacs/emacs_commands.csv</a>. I seem to be having a hard time with getting orderless to do that with <code>orderless-flex</code>, so I'm just going to remove that column of the CSV from my <a href="https://sachachua.com/blog/2026/10/emacs-carnival-oct-2026-exploring-keys-and-voice-input-in-emacs/emacs_commands.csv">emacs_commands.csv</a>.</li>
<li><a href="https://emacslisten.org/">Emacslisten</a> uses <a href="https://github.com/ErikPrantare/phony.el">Emacs Lisp macros</a> to define the command vocabulary. <a href="https://github.com/ErikPrantare/cursorfree.el">Cursorfree</a> defines a whole bunch of them, using <a href="https://github.com/ErikPrantare/hatty.el">hatty</a> for voice navigation within a buffer.</li>
<li><a href="https://github.com/jcaw/voicemacs">Voicemacs</a> defines its commands in Python in the user's Talon config (<a href="https://github.com/jcaw/talon_config/tree/master/emacs">see example</a>). It feels fairly complex, like it assumes it's being cloned as your <code>~/.talon/user</code> directory. It lets Emacs and Talon communicate via RPC to send additional context. It also extends some things like dired and company to make them more voice-friendly.</li>
</ul>

<p>
I'm new to both projects, so I'm not sure if I'm reading this right, but I think I might be able to use Emacslisten to define voice commands with Emacs Lisp, and then maybe someday use Voicemacs to provide richer context for some of those commands. For example, Voicemacs can list snippets, but I'm not quite sure how to use that yet.
</p>

<p>
It looks like I can use Talon for commands and my whisper.el setup for regular dictation at the same time. The Pipewire virtual sinks help with that, I think, since the programs don't have to have an exclusive lock on the audio device. This means that I can explore the kinds of vocabularies that people have set up while also taking advantage of greater accuracy and ease of correction in my whisper dictation workflow. I think I can use the Talon process socket to turn off recognition when I want to dictate using my whisper.el setup, and then I can turn it back on afterwards.
</p>

<p>
A note about the underlying speech recognition: <a href="https://talonvoice.com/">Talon</a> is cross-platform and free, but not open source. Subscribing to Talon (CAD 36/month) lets you use a Conformer + Whisper hybrid engine that uses whisper-large for more accuracy, but that's a bit on the expensive side for me. <a href="https://github.com/dictation-toolbox/dragonfly">Dragonfly</a> is a free open source engine that can use Kaldi or CMU Pocket Sphinx for speech recognition, but I'm not sure what the performance is like.
</p>

<p>
Interestingly, because Talon simulates keystrokes, using the commands from the community set means keys sometimes arrive out of order on my computer. "split solo" is supposed to run <code>M-x delete-other-windows</code>, but it sometimes ends up sending <code>M-x delete-other-wnidows</code> instead. This is the same sort of annoyance that gets in the way of typing quickly on my computer. Keystrokes get processed out of order when the CPU gets busy, which is part of the reason why I find dictation to be more reliable than typing sometimes. I should fix that someday, but my attempts so far aren't working. (I wonder if it has something to do with the GPU under Linux; maybe I should drop back down to CPU only since it turns out I can't use the GPU for much anyway.) Quick fix, let's try adding a brief delay in my <a href="https://sachachua.com/blog/2026/10/emacs-carnival-oct-2026-exploring-keys-and-voice-input-in-emacs/settings.talon">settings.talon</a>:
</p>

<pre class="example" id="org4ab5427">
settings():
    # Adds a small pause (in ms) between each character typed
    insert_wait = 5

    # Ensures modifiers (Shift/Ctrl) don't un-latch too fast
    key_wait = 1.0
</pre>

<p>
I think Voicemacs uses a sevver and and Emacslisten uses emacsclient to communicate with Emacs directly, so they probably won't run into this keystroke problem.
</p>

<p>
It might be interesting to see if I can port some of my simpler commands over to Emacslisten or straight Talon so that they're always active. Then I can slowly work on getting used to the other commands people find useful, or incorporating them into my setup.
</p>
</div>
</div>
<div id="outline-container-emacs-carnival-exploring-keys-and-voice-input-in-emacs-imagining-a-hybrid-approach-keyboard-voice-even-mouse-stylus" class="outline-3">
<h3 id="emacs-carnival-exploring-keys-and-voice-input-in-emacs-imagining-a-hybrid-approach-keyboard-voice-even-mouse-stylus"><a href="https://sachachua.com/blog/feed/atom/index.xml#emacs-carnival-exploring-keys-and-voice-input-in-emacs-imagining-a-hybrid-approach-keyboard-voice-even-mouse-stylus">Imagining a hybrid approach: keyboard, voice, even mouse/stylus?</a></h3>
<div class="outline-text-3" id="text-emacs-carnival-exploring-keys-and-voice-input-in-emacs-imagining-a-hybrid-approach-keyboard-voice-even-mouse-stylus">
<p>
I love shifting fluidly from one form of input to another, depending on what makes sense at that moment.
</p>

<p>
For example, <a href="https://sachachua.com/blog/2025/07/finding-the-shape-of-my-thoughts/">I often start my thoughts</a> by drawing on a light dotted grid using Noteful on my iPad. That lets me quickly cluster ideas spatially, drawing connections and highlighting words as I figure out what I want to say.
</p>

<p>
</p><div class="sketch-full"><a class="photoswipe" href="https://sketches.sachachua.com/filename/2026-10-07-01%20Experimenting%20with%20voice%20input%20in%20Emacs%20-%20rough%20braindump.jpeg" data-src="https://sketches.sachachua.com/static/2026-10-07-01%20Experimenting%20with%20voice%20input%20in%20Emacs%20-%20rough%20braindump.jpeg" data-title="2026-10-07-01 Experimenting with voice input in Emacs - rough braindump.jpeg" data-w="2900" data-h="2050"><picture>
      <img src="https://sketches.sachachua.com/static/2026-10-07-01%20Experimenting%20with%20voice%20input%20in%20Emacs%20-%20rough%20braindump.jpeg" width="2900" height="2050" alt="2026-10-07-01 Experimenting with voice input in Emacs - rough braindump.jpeg" loading="lazy" style="max-height: 90vw; height: auto; width: auto" decoding="async">
      <figcaption>2026-10-07-01 Experimenting with voice input in Emacs - rough braindump.jpeg</figcaption>
    </picture></a></div>
<p></p>

<p>
Then I use dictation and typing to sketch the outline, jumping around as thoughts occur to me. If I'm livestreaming at the same time, that helps me demonstrate things along the way and lets me benefit from people's questions. Dictation lets me explain things to people and capture the text at the same time.
</p>

<p>
I can move around with the keyboard, but it would be really cool to use voice for quick navigation between sections of my outline using either line numbers or words. I've implemented a "line" command that lets me jump to a line using the last two digits of its line number, since I probably won't have more than 100 lines visible on the screen at a time. For example, this line is currently 119, so referring to it as "nineteen" would work. I'd like to add more operations for editing the text. I think it would be great to be able to say "kill line 33" to delete that line or "move lines 16 to 20 after 27" to have it move those lines there.
</p>

<p>
I now have a <code>sacha-whisper-one-sentence-per-line</code> variable that splits up dictation if non-nil, so we'll see where those take me. Orukeet does a reasonable job of punctuating my sentences if I don't pause too much between phrases. <a href="https://sachachua.com/blog/2025/09/emacs-cycle-through-different-paragraph-formats-all-on-one-line-wrapped-max-one-sentence-per-line-one-sentence-per-line/">My M-q re-wraps paragraphs</a> between one sentence per line, one paragraph per line, and wrapping to fill-column, and it's probably the sort of thing that more voice commands would make even more convenient.
</p>

<p>
Maybe I can even use that spatial sense of a layout by touching buttons in an Emacs-served webpage on my tablet to direct my dictation to different places. <a href="https://github.com/larrasket/org-draw">Org-draw</a> uses a similar Emacs web server approach to let you draw on another device and embed the results into an Org file, and there are also simpler HTTP servers (<a target="_blank" href="https://melpa.org/#/web-server">web-server</a>, <a target="_blank" href="https://melpa.org/#/simple-httpd">simple-httpd</a>), so it's probably quite doable. I'm imagining something that takes the top-level items from my current nested list and makes them nice big buttons, so I could have something like "Introduction", "Keyboard", "Reasons", "Experiment", "Hybrid", and "Conclusion", and clicking on those could trigger a POST request to the server inside Emacs which moves my point accordingly. I might even have buttons for various commands. It sounds pretty straightforward to implement.
</p>

<p>
When my brain comes up with lots of interesting ideas, my org-capture voice commands let me choose which rabbit holes to postpone and which ones I want to dive into.
</p>

<p>
If I get interrupted by life, I can write on my phone while waiting for the kiddo. <a href="https://www.orgzlyrevived.com/">Orgzly Revived</a> and <a href="https://syncthing.net/">Syncthing</a> let me pick up where I left off.
</p>

<p>
As I get thoughts down, I can use keyboard shortcuts to rearrange things and then convert the list of sentences into paragraphs. <a href="https://sachachua.com/blog/2025/07/finding-unlinked-text/">I can easily turn text into links</a> using my favourites.
</p>

<p>
I can imagine combining the audio clips from the text properties with the videos and screenshots to create a quick narrated clip that I can edit (using Emacs, of course), or publishing the narration so that people can listen to it if they like.
</p>

<p>
This combination of drawing + audio + text works better for me than any of those components alone. Visuals give me anchors for my thoughts. Audio helps with the braindump. Text permits precise, searchable details we can copy. Like <a href="https://curious.port111.com/2026/08/22/will-voice-kill-the-keyboard.html">George Jones</a>, I find they all have their uses and their strengths.
</p>

<p>
When I try to dictate longer sections without that kind of visual support, I often lose my train of thought. I want to see where I've been and where I want to go. I don't trust LLMs to clean up that kind of rough transcript; the output doesn't quite resonate with me. I like keeping speech recognition constrained to sentences I can immediately check or reorganize, and I have the recordings as text properties so I can go back to that segment if I need to (at least during the current editing section). That way, I'm never left scratching my head and wondering what I meant.
</p>

<p>
I love that local speech recognition is getting better and better. I'm curious about whether small language models can do better turn detection to help compensate for my intra-phrase delays when I'm thinking of a word, and whether decision models can automatically classify a sentence into its place in my outline. I think it would be cool if embeddings or other language models could suggest related words or resources as I go along. Lots of interesting possibilities even with the technology that's already available.
</p>

<p>
Thanks to George Jones for hosting <a href="https://www.emacswiki.org/emacs/CarnivalOctober2026">this month's Emacs Carnival on input alternatives</a>. Check out the page for more posts!
</p>
</div>
</div>
<div><a href="https://sachachua.com/blog/2026/10/emacs-carnival-oct-2026-exploring-keys-and-voice-input-in-emacs/index.org">View Org source for this post</a></div><p>You can <a href="mailto:sacha@sachachua.com?subject=Comment%20on%20https%3A%2F%2Fsachachua.com%2Fblog%2F2026%2F10%2Femacs-carnival-oct-2026-exploring-keys-and-voice-input-in-emacs%2F&body=Name%20you%20want%20to%20be%20credited%20by%20(if%20any)%3A%20%0AMessage%3A%20%0ACan%20I%20share%20your%20comment%20so%20other%20people%20can%20learn%20from%20it%3F%20Yes%2FNo%0A">e-mail me at sacha@sachachua.com</a>.</p>]]></content>
		</entry><entry>
		<title type="html">Using Emacs to visualize speaking and target words/phrases in real-ish time</title>
		<link rel="alternate" type="text/html" href="https://sachachua.com/blog/2026/10/using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time/"/>
		<author><name><![CDATA[Sacha Chua]]></name></author>
		<updated>2026-10-07T11:47:04Z</updated>
    <published>2026-10-07T11:47:04Z</published>
    <category term="audio" />
<category term="speech-recognition" />
<category term="emacs" />
<category term="learning" />
<category term="visualization" />
		<id>https://sachachua.com/blog/2026/10/using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time/</id>
		<content type="html"><![CDATA[<div class="sticky-toc" id="org60bfade">
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="https://sachachua.com/blog/feed/atom/index.xml#writing-and-editing-speech-recognition-using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time-voice-activity-detection-and-speech-recognition">1. Voice activity detection and speech recognition</a></li>
<li><a href="https://sachachua.com/blog/feed/atom/index.xml#writing-and-editing-speech-recognition-using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time-noticing-bingo-phrases">2. Noticing bingo phrases</a></li>
</ul>
</div>

</div>


<figure id="org4276db7">
<img src="https://sachachua.com/blog/2026/10/using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time/2026-10-07_07-33-03.png" alt="2026-10-07_07-33-03.png">

<figcaption><span class="figure-number">Figure 1: </span>Screenshot showing my list of target phrases and which ones have been recognized</figcaption>
</figure>

<p>
When I'm working with a tutor to improve my French, I sometimes need
to push myself to provide more details when I'm sharing and ask more
follow-up questions in response to what they're saying, instead of
falling back to « D'accord » and « C'est cool. » Visualizing the
timeline in real-time lets me see if the turn-taking looks good. I
might even need to take a more active role in controlling the
conversation if I happen to be meeting a tutor who tends to go on
monologues.
</p>

<p>
When I'm talking out loud on my own for practice, this might also
nudge me to reduce the pauses and enrich my vocabulary by practising
saying things often enough that they become more automatic.
</p>
<div id="outline-container-writing-and-editing-speech-recognition-using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time-voice-activity-detection-and-speech-recognition" class="outline-3">
<h3 id="writing-and-editing-speech-recognition-using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time-voice-activity-detection-and-speech-recognition"><span class="section-number-3">1.</span> <a href="https://sachachua.com/blog/feed/atom/index.xml#writing-and-editing-speech-recognition-using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time-voice-activity-detection-and-speech-recognition">Voice activity detection and speech recognition</a></h3>
<div class="outline-text-3" id="text-writing-and-editing-speech-recognition-using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time-voice-activity-detection-and-speech-recognition">
<p>
This code uses this server <a href="https://sachachua.com/blog/2026/10/using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time/asr.py">vad-file.py</a>, which I generated with Google Gemini. It emits JSONL for voice activity detection events (start/stop) and uses Orukeet to transcribe the speech once the voice activity detection notices it's finished. I also use spacy to look up token information because I want to someday colour the nouns by gender, which might allow me to correct myself in the next sentence instead of hesitating in the previous one.
</p>

<details><summary>code for sacha-vad-tutor</summary>
<div class="org-src-container">
<pre class="src src-emacs-lisp"><code><span class="org-comment-delimiter">;; </span><span class="org-comment">Report on the balance between my tutor and me</span>
(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-vad-tutor-process</span> nil)
(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-vad-tutor-dir</span> <span class="org-string">"~/vendor/orukeet"</span>)
(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-vad-tutor-command</span> <span class="org-highlight-quoted-quote">`</span>(,(expand-file-name <span class="org-string">".venv/bin/python"</span> sacha-vad-tutor-dir)
                                  <span class="org-string">"asr.py"</span>
                                  <span class="org-string">"&#45;&#45;spacy-model"</span>
                                  <span class="org-string">"fr_dep_news_trf"</span>
                                  <span class="org-string">"-s"</span> <span class="org-string">"300"</span> <span class="org-string">"-t"</span>
                                  <span class="org-string">"VirtualMicSink.monitor=sacha"</span> <span class="org-string">"alsa_output.usb-AT_AT2040USB_202011110001-00.analog-stereo.monitor=other"</span>))
(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-vad-tutor-events</span> nil <span class="org-doc">"List of events as an list of alists (label start stop duration)."</span>)
(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-vad-tutor-labels</span> <span class="org-highlight-quoted-quote">'</span>(<span class="org-string">"sacha"</span> <span class="org-string">"other"</span>))
(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-vad-tutor-summary</span> <span class="org-highlight-quoted-quote">'</span>((<span class="org-string">"sacha"</span> . 0)
                                  (<span class="org-string">"other"</span> . 0)))
(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-vad-tutor-session-length</span> (* 60 60) <span class="org-doc">"Number of seconds to use for scale."</span>)

(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-vad-tutor-update-view</span> ()
  <span class="org-doc">"Visualize the last 3 minutes and the overview of the session.</span>
<span class="org-doc">Also keep track of target phrases."</span>
  (<span class="org-keyword">interactive</span>)
  (<span class="org-keyword">with-current-buffer</span> (get-buffer-create <span class="org-string">"*tutor stats*"</span>)
    (erase-buffer)
    (<span class="org-keyword">let*</span> ((total (apply <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">+</span> (mapcar <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">cdr</span> sacha-vad-tutor-summary)))
           (height 30)
           (width (window-width nil t))
           (max-seconds
            (<span class="org-keyword">if</span> sacha-vad-tutor-events
                (apply <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">max</span> (mapcar (<span class="org-keyword">lambda</span> (o) (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">end</span> o))
                                    sacha-vad-tutor-events))
              0))
           (threshold 180)              <span class="org-comment-delimiter">; </span><span class="org-comment">last three minutes</span>
           (threshold-seconds (- max-seconds threshold))
           (recent
            (seq-keep
             (<span class="org-keyword">lambda</span> (o)
               (<span class="org-keyword">when</span> (&gt;= (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">start</span> o)
                         threshold-seconds)
                 (<span class="org-keyword">let-alist</span> o
                   <span class="org-highlight-quoted-quote">`</span>((label . ,.label)
                     (start . ,(- .start threshold-seconds))
                     (end . ,(- .end threshold-seconds))))))
             (copy-sequence sacha-vad-tutor-events)))
           (recent-total (apply <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">+</span> (mapcar (<span class="org-keyword">lambda</span> (o)
                                             (-
                                              (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">end</span> o)
                                              (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">start</span> o)))
                                           recent))))
      (<span class="org-keyword">save-excursion</span>
        (insert
         (format <span class="org-string">"Last %d minute%s:\n"</span>
                 (/ threshold 60)
                 (<span class="org-keyword">if</span> (&gt; (/ threshold 60) 1)
                     <span class="org-string">"s"</span>
                   <span class="org-string">""</span>))
         (mapconcat
          (<span class="org-keyword">lambda</span> (o)
            (format <span class="org-string">"%d%% %s\n"</span>
                    (/ (* 100.0 (cdr o)) recent-total)
                    (car o)))
          (seq-map
           (<span class="org-keyword">lambda</span> (group)
             (cons (car group)
                   (apply <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">+</span> (mapcar (<span class="org-keyword">lambda</span> (o)
                                       (-
                                        (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">end</span> o)
                                        (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">start</span> o)))
                                     (cdr group)))))
           (seq-group-by (<span class="org-keyword">lambda</span> (o) (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">label</span> o)) recent)))
         <span class="org-string">"\n"</span>)
        (svg-insert-image
         (sacha-vad-visualize
          sacha-vad-tutor-labels
          recent
          t
          width height))
        (insert
         <span class="org-string">"\nTotal:\n"</span>

         (mapconcat
          (<span class="org-keyword">lambda</span> (o)
            (format <span class="org-string">"%d%% %s\n"</span>
                    (/ (* 100.0 (cdr o)) total)
                    (car o)))
          sacha-vad-tutor-summary))
        (svg-insert-image
         (sacha-vad-visualize sacha-vad-tutor-labels sacha-vad-tutor-events t
                              width height
                              sacha-vad-tutor-session-length))
        (insert <span class="org-string">"\n\n"</span>  (sacha-learn-lang-bingo-summary))))))

(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-vad-handle-end-event</span> (data)
  <span class="org-doc">"Handle the end event."</span>
  (<span class="org-keyword">let</span> ((event (list
                (cons <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">label</span> (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">label</span> data))
                (cons <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">start</span> (- (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">timestamp</span> data)
                                (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">duration</span> data)
                                (<span class="org-keyword">or</span> sacha-vad-tutor-start-seconds 0)))
                (cons <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">end</span> (- (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">timestamp</span> data)
                              (<span class="org-keyword">or</span> sacha-vad-tutor-start-seconds 0))))))
    (<span class="org-keyword">push</span> event sacha-vad-tutor-events)
    (<span class="org-keyword">let-alist</span> data
      (<span class="org-keyword">incf</span> (alist-get (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">label</span> data) sacha-vad-tutor-summary 0 nil <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">string=</span>)
            .duration))
    (sacha-vad-tutor-update-view)))

(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-vad-event-handler-functions</span> <span class="org-highlight-quoted-quote">'</span>(sacha-vad-speech-process) <span class="org-doc">"Functions to call with the VAD/transcription events."</span>)

(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-vad-process-my-speech</span> nil <span class="org-doc">"Non-nil means process my speech through the whisper setup."</span>)
(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-vad-speech-process</span> (data)
  <span class="org-doc">"Process DATA through my whisper input process if it's my speech.</span>
<span class="org-doc">Add to `</span><span class="org-doc"><span class="org-constant">sacha-vad-event-handler-functions</span></span><span class="org-doc">'."</span>
  (<span class="org-keyword">when</span> (<span class="org-keyword">and</span> sacha-vad-process-my-speech
             (string= (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">event</span> data) <span class="org-string">"final"</span>)
             (string= (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">label</span> data) sacha-vad-my-label))
    (<span class="org-keyword">with-current-buffer</span> (get-buffer-create whisper&#45;&#45;stdout-buffer-name)
      (erase-buffer)
      (insert (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">text</span> data))
      (goto-char (point-min)))
    (whisper&#45;&#45;handle-transcription-output nil (get-buffer-create whisper&#45;&#45;stdout-buffer-name))))

(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-vad-tutor-filter</span> (proc string)
  <span class="org-doc">"Add and parse."</span>
  (<span class="org-keyword">when</span> (buffer-live-p (process-buffer proc))
    <span class="org-comment-delimiter">;; </span><span class="org-comment">split the string by newline?</span>
    (<span class="org-keyword">let</span> ((data (<span class="org-keyword">with-current-buffer</span> (process-buffer proc)
                  (goto-char (point-max))
                  (<span class="org-keyword">save-excursion</span>
                    (insert string))
                  (<span class="org-keyword">catch</span> <span class="org-highlight-quoted-quote">'</span><span class="org-constant">waiting</span>
                    (<span class="org-keyword">unless</span> (<span class="org-keyword">or</span> (eobp) (looking-at <span class="org-string">"\n*$"</span>))
                      (json-read))))))
      (run-hook-with-args <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">sacha-vad-event-handler-functions</span> data)
      (<span class="org-keyword">when</span> (string= (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">event</span> data) <span class="org-string">"end"</span>)
        (sacha-vad-handle-end-event data))
      (<span class="org-keyword">when</span> (string= (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">event</span> data) <span class="org-string">"final"</span>)
        (sacha-vad-handle-text-event data)))))

(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-vad-last-speaker</span> nil <span class="org-doc">"Previous speaker."</span>)

(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-vad-transcript-buffer</span> nil <span class="org-doc">"If non-nil, add speech to this buffer."</span>)
(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-vad-add-to-transcript</span> (text)
  <span class="org-doc">"Add TEXT to the transcript buffer."</span>
  (<span class="org-keyword">when</span> sacha-vad-transcript-buffer
    (<span class="org-keyword">with-current-buffer</span> (get-buffer-create sacha-vad-transcript-buffer)
      (set (make-local-variable <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">window-point-insertion-type</span>) t)
      (<span class="org-keyword">save-excursion</span>
        (goto-char (point-max))
        (insert text)))))

(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-vad-my-label</span> <span class="org-string">"sacha"</span>)
(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-vad-handle-text-event</span> (data)
  (sacha-vad-add-to-transcript
   (concat
    (<span class="org-keyword">if</span> (string= sacha-vad-last-speaker (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">label</span> data))
        <span class="org-string">" "</span>
      (concat (<span class="org-keyword">if</span> (bobp) <span class="org-string">""</span> <span class="org-string">"\n\n"</span>) (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">label</span> data) <span class="org-string">": "</span>))
    (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">text</span> data)))
  (<span class="org-keyword">setq</span> sacha-vad-last-speaker (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">label</span> data))
  (<span class="org-keyword">when</span> (string= (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">label</span> data) sacha-vad-my-label)
    (sacha-learn-lang-notice-bingo-words (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">text</span> data))))

(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-vad-tutor-start</span> ()
  <span class="org-doc">"Start the process."</span>
  (<span class="org-keyword">interactive</span>)
  (sacha-vad-tutor-ensure)
  (<span class="org-keyword">setq</span> sacha-vad-tutor-summary <span class="org-highlight-quoted-quote">'</span>((<span class="org-string">"sacha"</span> . 0)
                                  (<span class="org-string">"other"</span> . 0))
        sacha-vad-tutor-events nil)
  (<span class="org-keyword">with-current-buffer</span> (get-buffer-create <span class="org-string">"*Transcript*"</span>)
    (erase-buffer)
    (display-buffer (current-buffer)))
  (display-buffer (get-buffer-create <span class="org-string">"*tutor stats*"</span>)))

(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-vad-tutor-ensure</span> ()
  <span class="org-doc">"Start the process if it's not already running."</span>
  (<span class="org-keyword">interactive</span>)
  (<span class="org-keyword">unless</span> (process-live-p sacha-vad-tutor-process)
    (<span class="org-keyword">setq</span> sacha-vad-tutor-process-start-time (current-time))
    (<span class="org-keyword">setq</span> sacha-vad-tutor-start-seconds 0)
    (<span class="org-keyword">let</span> ((default-directory sacha-vad-tutor-dir))
      (<span class="org-keyword">setq</span> sacha-vad-tutor-process
            (make-process
             <span class="org-builtin">:name</span> <span class="org-string">"vad-tutor"</span>
             <span class="org-builtin">:command</span> sacha-vad-tutor-command
             <span class="org-builtin">:connection-type</span> <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">pipe</span>
             <span class="org-builtin">:buffer</span> (get-buffer-create <span class="org-string">"*vad-tutor*"</span>)
             <span class="org-builtin">:stderr</span> (get-buffer-create <span class="org-string">"*vad-tutor-err*"</span>)
             <span class="org-builtin">:filter</span> <span class="org-highlight-quoted-quote">#'</span><span class="org-highlight-quoted-symbol">sacha-vad-tutor-filter</span>)))))

(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-vad-tutor-stop</span> ()
  <span class="org-doc">"Stop the process."</span>
  (<span class="org-keyword">interactive</span>)
  (interrupt-process sacha-vad-tutor-process))

<span class="org-comment-delimiter">;;;</span><span class="org-comment">###</span><span class="org-comment"><span class="org-warning">autoload</span></span>
(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-js-parse-jsonl-file</span> (file)
  <span class="org-doc">"Parse jsonl as a list"</span>
  (<span class="org-keyword">let</span> (results)
    (<span class="org-keyword">with-temp-buffer</span>
      (insert-file-contents file)
      (goto-char (point-min))
      (<span class="org-keyword">while</span> (not (eobp))
        (<span class="org-keyword">condition-case</span> nil
            (<span class="org-keyword">push</span> (json-read) results)
          (<span class="org-warning">error</span> (goto-char (point-max))))))
    (nreverse results)))

(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-vad-tutor-start-seconds</span> 0 <span class="org-doc">"Number of seconds to consider as the start."</span>)
(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-vad-tutor-process-start-time</span> nil <span class="org-doc">"Time that the process started."</span>)

<span class="org-comment-delimiter">;;;</span><span class="org-comment">###</span><span class="org-comment"><span class="org-warning">autoload</span></span>
(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-vad-tutor-reset-clock</span> ()
  <span class="org-doc">"Reset the start of the session."</span>
  (<span class="org-keyword">interactive</span>)
  (<span class="org-keyword">setq</span> sacha-vad-tutor-start-seconds
        (time-to-seconds (time-subtract (current-time)
                                        sacha-vad-tutor-process-start-time)))
  (mapcar (<span class="org-keyword">lambda</span> (o) (setcdr o 0)) sacha-vad-tutor-summary)
  (<span class="org-keyword">setq</span> sacha-vad-tutor-events nil))

(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-vad-visualize</span> (labels list <span class="org-type">&amp;optional</span> output-file width height max-seconds)
  (<span class="org-keyword">setq</span> height (<span class="org-keyword">or</span> height 25))
  (<span class="org-keyword">setq</span> width (<span class="org-keyword">or</span> width (window-width nil t)))
  (<span class="org-keyword">let*</span> ((svg (svg-create width height))
         (max-seconds (max
                       (<span class="org-keyword">or</span> max-seconds 0)
                       (<span class="org-keyword">if</span> list
                           (apply <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">max</span> (mapcar (<span class="org-keyword">lambda</span> (o) (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">end</span> o))
                                               list))
                         0)))
         (pixels-per-second (/ (* 1.0 width) max-seconds))
         (row-height (/ height (length labels))))
    (<span class="org-keyword">dolist</span> (o list)
      (<span class="org-keyword">let-alist</span> o
        (<span class="org-keyword">let</span> ((y (* row-height (<span class="org-keyword">or</span> (seq-position labels .label <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">string=</span>) -1))))
          (<span class="org-keyword">when</span> (&gt;= y 0)
            (svg-rectangle
             svg
             (* .start pixels-per-second)
             y
             (* (- .end .start) pixels-per-second)
             row-height <span class="org-builtin">:fill</span> <span class="org-string">"green"</span>)))))
    (<span class="org-keyword">cond</span>
     ((stringp output-file)
      (<span class="org-keyword">with-temp-file</span> output-file
        (svg-print svg)))
     (output-file
      svg)
     (t
      (<span class="org-keyword">with-current-buffer</span> (get-buffer-create <span class="org-string">"*vad*"</span>)
        (goto-char (point-min))
        (display-buffer (current-buffer))
        (erase-buffer)
        (svg-insert-image svg))))))

(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-vad-stats</span> (labels list)
  <span class="org-doc">"Return the balance of time talking as (label total percentage)."</span>
  (<span class="org-keyword">let*</span> ((max-seconds (apply <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">+</span> (mapcar
                                 (<span class="org-keyword">lambda</span> (o) (<span class="org-keyword">let-alist</span> o (- .end .start)))
                                 list)))
         (durations (mapcar (<span class="org-keyword">lambda</span> (o)
                            (cons
                             (car o)
                             (mapcar (<span class="org-keyword">lambda</span> (e) (<span class="org-keyword">let-alist</span> e (- .end .start)))
                                     (cdr o))))
                          (seq-group-by (<span class="org-keyword">lambda</span> (o) (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">label</span> o))
                                        list))))
    (seq-map
     (<span class="org-keyword">lambda</span> (label)
       (<span class="org-keyword">let*</span> ((row (cdr (assoc label durations)))
              (total (apply <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">+</span> row)))
         <span class="org-highlight-quoted-quote">`</span>((label . ,label)
           (total . ,total)
           (count . ,(length row))
           (percentage . ,(<span class="org-keyword">and</span> total max-seconds (&gt; max-seconds 0) (* 100.0 (/ total max-seconds)))))))
     labels)))

<span class="org-comment-delimiter">;; </span><span class="org-comment">(sacha-vad-stats '("sacha" "tutor") (seq-take (sacha-js-parse-jsonl-file "~/proj/speech/output2.log") 5))</span>
<span class="org-comment-delimiter">;; </span><span class="org-comment">(sacha-vad-stats '("sacha" "tutor") (sacha-js-parse-jsonl-file "~/proj/speech/output.log"))</span>
<span class="org-comment-delimiter">;; </span><span class="org-comment">(sacha-vad-visualize '("sacha" "tutor") (sacha-js-parse-jsonl-file "~/proj/speech/output.log"))</span>
<span class="org-comment-delimiter">;; </span><span class="org-comment">(sacha-vad-visualize '("sacha" "tutor") (seq-take (sacha-js-parse-jsonl-file "~/proj/speech/output2.log") 30))</span>

(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-vad-tutor-group-output</span> (files)
  (<span class="org-keyword">let</span> ((grouped-files (seq-group-by
                        (<span class="org-keyword">lambda</span> (o)
                          (substring (file-name-base o) 0 10))
                        files)))
    (mapcar
     (<span class="org-keyword">lambda</span> (group)
       (<span class="org-keyword">let</span> ((start 0))
         (cons (car (cdr group))
               (seq-reduce
                (<span class="org-keyword">lambda</span> (prev file)
                  (append prev
                          (<span class="org-keyword">let</span> ((max-seconds 0))
                            (<span class="org-keyword">prog1</span> (mapcar (<span class="org-keyword">lambda</span> (event)
                                             (<span class="org-keyword">incf</span> (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">start</span> event) start)
                                             (<span class="org-keyword">incf</span> (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">end</span> event) start)
                                             (<span class="org-keyword">setq</span> max-seconds (max (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">end</span> event) max-seconds))
                                             event)
                                           (sacha-js-parse-jsonl-file file))
                              (<span class="org-keyword">setq</span> start max-seconds)))))
                (cdr group)
                nil))))
     grouped-files)))

(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-vad-tutor-make-table</span> (files <span class="org-type">&amp;optional</span> width height)
  <span class="org-doc">"Make a summary table."</span>
  (<span class="org-keyword">let</span> ((labels sacha-vad-tutor-labels)
        (width (<span class="org-keyword">or</span> width 500))
        (height (<span class="org-keyword">or</span> height 30)))
    <span class="org-comment-delimiter">;; </span><span class="org-comment">combine data as needed</span>
    (append
     <span class="org-highlight-quoted-quote">'</span>((<span class="org-string">"Date"</span> <span class="org-string">"Tutor"</span> <span class="org-string">"Minutes"</span> <span class="org-string">"%"</span> <span class="org-string">"Visualization"</span>) hline)
     (seq-map
      (<span class="org-keyword">lambda</span> (group)
        (<span class="org-keyword">let*</span> ((list (cdr group))
               (base (file-name-base (car group))))
          (<span class="org-keyword">if</span> list
              (<span class="org-keyword">let-alist</span> (car (sacha-vad-stats labels list))
                (<span class="org-keyword">let</span> ((svg-name
                       (expand-file-name
                        (concat (file-name-base (car group)) <span class="org-string">"-"</span> .label <span class="org-string">".svg"</span>)
                        <span class="org-string">"~/proj/french/conversation"</span>)))
                  (sacha-vad-visualize
                   (list .label)
                   list
                   svg-name
                   width
                   height)
                  (list
                   (format-time-string <span class="org-string">"%Y-%m-%d"</span>
                                       (seconds-to-time
                                        (sacha-filename-timestamp (car group))))
                   <span class="org-comment-delimiter">;; </span><span class="org-comment">(org-link-make-string (concat "file:" o) "file")</span>
                   (<span class="org-keyword">if</span> (string-match <span class="org-string">"-conversation-</span><span class="org-string"><span class="org-regexp-grouping-backslash">\\</span></span><span class="org-string"><span class="org-regexp-grouping-construct">(</span></span><span class="org-string">[</span><span class="org-string"><span class="org-negation-char">^</span></span><span class="org-string">\\.]+</span><span class="org-string"><span class="org-regexp-grouping-backslash">\\</span></span><span class="org-string"><span class="org-regexp-grouping-construct">)</span></span><span class="org-string">"</span> base)
                       (s-capitalize (substring (match-string 1 base) 0 1))
                     <span class="org-string">""</span>)

                   (round (/ .total 60))
                   (format <span class="org-string">"%d%%"</span> .percentage)
                   (org-link-make-string (concat <span class="org-string">"file:"</span> svg-name)
                                         (concat <span class="org-string">"file:"</span> svg-name))
                   )))
            (list <span class="org-string">"?"</span>))))
      (sacha-vad-tutor-group-output files))
     nil)))
</code></pre>
</div>

</details>
</div>
</div>
<div id="outline-container-writing-and-editing-speech-recognition-using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time-noticing-bingo-phrases" class="outline-3">
<h3 id="writing-and-editing-speech-recognition-using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time-noticing-bingo-phrases"><span class="section-number-3">2.</span> <a href="https://sachachua.com/blog/feed/atom/index.xml#writing-and-editing-speech-recognition-using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time-noticing-bingo-phrases">Noticing bingo phrases</a></h3>
<div class="outline-text-3" id="text-writing-and-editing-speech-recognition-using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time-noticing-bingo-phrases">
<p>
Here's the code that reminds me to use the words or expressions on my
to-do list, and then keeps track of how often I've used them,
prioritizes the ones that I haven't used yet, and displays these.
It can work with either my Whisper dictation workflow or the VAD
events server described above.
</p>

<p>
I keep the list of expressions in <a href="https://sachachua.com/blog/2026/10/using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time/bingo.txt">file:///home/sacha/proj/french/bingo.txt</a>.
</p>

<details><summary>Code to notice when I've used an expression</summary>
<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-learn-lang-bingo-word-file</span> <span class="org-string">"~/proj/french/bingo.txt"</span>)
(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-learn-lang-bingo-words</span> nil <span class="org-doc">"List of words."</span>)
(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha-learn-lang-bingo-words-hash</span> nil <span class="org-doc">"Data for the counts."</span>)

<span class="org-comment-delimiter">;;;</span><span class="org-comment">###</span><span class="org-comment"><span class="org-warning">autoload</span></span>
(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-learn-lang-bingo-words</span> ()
  <span class="org-doc">"Load the list of words from the file."</span>
  (<span class="org-keyword">interactive</span>)
  (<span class="org-keyword">setq</span> sacha-learn-lang-bingo-words
        (seq-map (<span class="org-keyword">lambda</span> (o)
                   (<span class="org-keyword">when</span> (= (length o) 1)
                     (<span class="org-keyword">setq</span> o (list (car o) 0)))
                   (<span class="org-keyword">setq</span> o (append o (list
                                      (string-trim (replace-regexp-in-string
                                                    <span class="org-string">" *\\[.+?\\] *"</span> <span class="org-string">" "</span>
                                                    (car o))))))
                   o)
                 (pcsv-parse-file sacha-learn-lang-bingo-word-file)))
  sacha-learn-lang-bingo-words)

<span class="org-comment-delimiter">;;;</span><span class="org-comment">###</span><span class="org-comment"><span class="org-warning">autoload</span></span>
(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-learn-lang-bingo-handler</span> (event)
  <span class="org-doc">"Manually register the event."</span>
  (<span class="org-keyword">interactive</span> <span class="org-string">"e"</span>)
    (<span class="org-keyword">let*</span> ((pos (posn-point (event-end event)))
           (val (get-text-property pos <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">bingo</span>)))
      (<span class="org-keyword">when</span> val
        (sacha-learn-lang-notice-bingo-words val))))

(<span class="org-keyword">defvar-keymap</span> sacha-learn-lang-bingo-map
  <span class="org-string">"&lt;mouse-1&gt;"</span> <span class="org-highlight-quoted-quote">#'</span><span class="org-highlight-quoted-symbol">sacha-learn-lang-bingo-handler</span>)

<span class="org-comment-delimiter">;;;</span><span class="org-comment">###</span><span class="org-comment"><span class="org-warning">autoload</span></span>
(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-learn-lang-bingo-summary</span> ()
  <span class="org-doc">"Summarize the words to say."</span>
  (<span class="org-keyword">let</span> ((target (seq-filter (<span class="org-keyword">lambda</span> (row) (= (elt row 1) 0))
                            sacha-learn-lang-bingo-words))
        (yay (seq-filter (<span class="org-keyword">lambda</span> (row) (&gt; (elt row 1) 0))
                         sacha-learn-lang-bingo-words)))
    (concat
     (<span class="org-keyword">if</span> target
         (concat <span class="org-string">"Target: "</span>
                 (mapconcat (<span class="org-keyword">lambda</span> (row)
                              (propertize
                               (car row)
                               <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">keymap</span> sacha-learn-lang-bingo-map
                               <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">bingo</span> (car row)))
                            target
                            <span class="org-string">"; "</span>)
                 <span class="org-string">"\n\n"</span>)
       <span class="org-string">""</span>)
     (<span class="org-keyword">if</span> yay
         (concat
          <span class="org-string">"Yay! "</span>
          (mapconcat (<span class="org-keyword">lambda</span> (row)
                       (propertize (format <span class="org-string">"%s (%s)"</span> (car row) (elt row 1))
                                   <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">keymap</span> sacha-learn-lang-bingo-map
                                   <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">bingo</span> (car row)))
                     (seq-filter (<span class="org-keyword">lambda</span> (row) (&gt; (elt row 1) 0))
                                 sacha-learn-lang-bingo-words)
                     <span class="org-string">"; "</span>)
          <span class="org-string">"\n\n"</span>)
       <span class="org-string">""</span>))))

<span class="org-comment-delimiter">;;;</span><span class="org-comment">###</span><span class="org-comment"><span class="org-warning">autoload</span></span>
(<span class="org-keyword">defun</span> <span class="org-function-name">sacha-learn-lang-notice-bingo-words</span> (text)
  <span class="org-doc">"Look for the bingo words in TEXT and celebrate when I use them.</span>
<span class="org-doc">Add to `</span><span class="org-doc"><span class="org-constant">whisper-insert-text-at-point</span></span><span class="org-doc">'."</span>
  (<span class="org-keyword">when</span> text
    (<span class="org-keyword">unless</span> sacha-learn-lang-bingo-words (sacha-learn-lang-bingo-words))
    (<span class="org-keyword">let</span> ((found (seq-find
                  (<span class="org-keyword">lambda</span> (o)
                    (<span class="org-keyword">and</span> (elt o 2)
                         (string-match (concat <span class="org-string">"\\&lt;"</span> (elt o 2)) text)))
                  sacha-learn-lang-bingo-words)))
      (<span class="org-keyword">when</span> found
        (<span class="org-keyword">incf</span> (elt found 1))
        (sacha-vad-tutor-update-view)
        (<span class="org-keyword">with-current-buffer</span> (get-buffer-create <span class="org-string">"*Bingo*"</span>)
          (erase-buffer)
          (insert (sacha-learn-lang-bingo-summary))))))
  text)
</code></pre>
</div>

</details>
</div>
</div>

<div class="note">This is part of my <a href="https://sachachua.com/dotemacs#writing-and-editing-speech-recognition-reporting-speaking-stats-balance">EmacsConfiguration.</a></div><div><a href="https://sachachua.com/blog/2026/10/using-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time/index.org">View Org source for this post</a></div><p>You can <a href="mailto:sacha@sachachua.com?subject=Comment%20on%20https%3A%2F%2Fsachachua.com%2Fblog%2F2026%2F10%2Fusing-emacs-to-visualize-speaking-and-target-words-phrases-in-real-ish-time%2F&body=Name%20you%20want%20to%20be%20credited%20by%20(if%20any)%3A%20%0AMessage%3A%20%0ACan%20I%20share%20your%20comment%20so%20other%20people%20can%20learn%20from%20it%3F%20Yes%2FNo%0A">e-mail me at sacha@sachachua.com</a>.</p>]]></content>
		</entry><entry>
		<title type="html">Categorizing Emacs News items by voice in Org Mode</title>
		<link rel="alternate" type="text/html" href="https://sachachua.com/blog/2026/03/categorizing-emacs-news-items-by-voice-in-org-mode/"/>
		<author><name><![CDATA[Sacha Chua]]></name></author>
		<updated>2026-03-24T01:19:29Z</updated>
    <published>2026-03-24T01:19:29Z</published>
    <category term="speech" />
<category term="speech-recognition" />
<category term="emacs" />
<category term="org" />
		<id>https://sachachua.com/blog/2026/03/categorizing-emacs-news-items-by-voice-in-org-mode/</id>
		<content type="html"><![CDATA[<p>
I'm having fun exploring which things might actually be easier to do by voice than by typing. For example, after I wrote some code to <a href="https://sachachua.com/dotemacs#writing-and-editing-speech-recognition-expanding-yasnippet-by-voice">expand yasnippets by voice</a>, I realized that it was easier to:
</p>

<ol class="org-ol">
<li>press my shortcut,</li>
<li>say "okay, define interactive function",</li>
<li>and then press my shortcut again,</li>
</ol>

<p>
than to:
</p>

<ol class="org-ol">
<li>mentally say it,</li>
<li>get the first initials,</li>
<li>type in "dfi",</li>
<li>and press Tab to expand.</li>
</ol>

<p>
Another area where I do this kind of mental translation for keyboard shortcuts is when I categorize dozens of Emacs-related links each week for <a href="https://sachachua.com/blog/category/emacs-news">Emacs News</a>. I used to do this by hand. Then I wrote a function to try to guess the category based on regular expressions (<code>my-emacs-news-guess-category</code> in <a href="https://raw.githubusercontent.com/sachac/emacs-news/refs/heads/master/index.org">emacs-news/index.org</a>, which is large). Then I set up a menu that lets me <a href="https://sachachua.com/blog/2019/06/making-a-numpad-based-hydra-for-categorizing-org-list-items/">press numbers corresponding to the most frequent categories</a> and use tab completion for the rest. 1 is Emacs Lisp, 2 is Emacs development, 3 is Emacs configuration, 4 is appearance, 5 is navigation, and so on. It's not very efficient, but some of it has at least gotten into muscle memory, which is also part of why it's hard to change the mapping. I don't come across that many links for Emacs development or Spacemacs, and I could probably change them to something else, but&hellip; Anyway.
</p>


<figure id="org36cd391">
<a href="https://sachachua.com/blog/2026/03/categorizing-emacs-news-items-by-voice-in-org-mode/2026-03-23_20-38-33.png"><img src="https://sachachua.com/blog/2026/03/categorizing-emacs-news-items-by-voice-in-org-mode/2026-03-23_20-38-33.png" alt="2026-03-23_20-38-33.png"></a>

<figcaption><span class="figure-number">Figure 1: </span>Screenshot of my menu for categorizing links</figcaption>
</figure>

<p>
I wanted to see if I could categorize links by voice instead. I might not always be able to count on being able to type a lot, and it's always fun to experiment with other modes of input. Here's a demonstration showing how Emacs can automatically open the URLs, wait for voice input, and categorize the links using a reasonably close match. The <code>*Messages*</code> buffer displays the recognized output to help with debugging.
</p>

<div class="media-post" id="org09d244a">
<p>
</p><figure><video controls="1" src="https://sachachua.com/blog/2026/03/categorizing-emacs-news-items-by-voice-in-org-mode/2026-03-23-compressed.webm" type="video/webm"><a href="https://sachachua.com/blog/2026/03/categorizing-emacs-news-items-by-voice-in-org-mode/2026-03-23-compressed.webm">Download the video</a></video><figcaption><div>Screencast with audio: categorizing links by voice</div></figcaption></figure>
<p></p>

</div>

<p>
This is how it works:
</p>

<ol class="org-ol">
<li>It starts an <code>ffmpeg</code> recording process.</li>
<li>It starts <a href="https://github.com/snakers4/silero-vad">Silero voice activity detection</a>.</li>
<li>When it detects that speech has ended, it use <code>curl</code> to send the WAV to an OpenAI-compatible server (in my case, <a href="https://speaches.ai/">Speaches</a> with the <code>Systran/faster-whisper-base.en</code> model) for transcription, along with a prompt to try to influence the recognition.</li>
<li>It compares the result with the candidates using <code>string-distance</code> for an approximate match. It calls the code to move the current item to the right category, creating the category if needed.</li>
</ol>

<p>
Since this doesn't always result in the right match, I added an Undo command. I also have a Delete command for removing the current item, Scroll Up and Scroll Down, and a way to quit.
</p>
<div id="outline-container-categorizing-emacs-news-items-by-voice-in-org-mode-initial-thoughts" class="outline-3">
<h3 id="categorizing-emacs-news-items-by-voice-in-org-mode-initial-thoughts">Initial thoughts</h3>
<div class="outline-text-3" id="text-categorizing-emacs-news-items-by-voice-in-org-mode-initial-thoughts">
<p>
I used it to categorize lots of links in this week's Emacs News, and I think it's promising. I loved the way my hands didn't have to hover over the number keys or move between those and the characters. Using voice activity detection meant that I could just keep dictating categories instead of pressing keyboard shortcuts or using the foot pedal I recently dusted off. There's a slight delay, of course, but I think it's worth it. If this settles down and becomes a solid part of my workflow, I might even be able to knit or hand-sew while doing this step, or simply do some stretching exercises.
</p>

<p>
<b>What about using streaming speech recognition?</b> I've written some code to <a href="https://sachachua.com/dotemacs#writing-and-editing-speech-recognition-streaming-speech-recognition-into-emacs-using-google-chrome-web-speech-api">use streaming speech recognition</a>, but the performance wasn't good enough when I tried it on my laptop (Lenovo P52 released in 2018, no configured GPU under Linux). The streaming server dropped audio segments in order to try to catch up. I'd rather have everything transcribed at the level of the model I want, even if I have to wait a little while. I also tried <a href="https://sachachua.com/dotemacs/index.html#writing-and-editing-speech-recognition-streaming-speech-recognition-into-emacs-using-google-chrome-web-speech-api">using the Web Speech API in Google Chrome for real-time speech transcription</a>, but it's a little finicky. I'm happy with the performance I get from either <a href="https://sachachua.com/blog/2026/01/queue-multiple-transcriptions-with-whisper-el-speech-recognition/">manually queueing speech segments</a> or <a href="https://sachachua.com/blog/2026/01/using-silero-voice-activity-detection-to-automatically-queue-multiple-transcriptions-with-natrys-whisper-el/">using VAD</a> and then using batch speech recognition with a model that's kept in memory (which is why I use a local server instead of a command-line tool). Come to think of it, I should try this with a higher-quality model like medium or large, just in case the latency turns out to be not that much more for this use case.
</p>

<p>
<b>What about external voice control systems</b> like <a href="https://talonvoice.com/">Talon Voice</a> or <a href="https://www.cursorless.org/">Cursorless</a>? They seem like neat ideas and lots of people use them. I think hacking something into Emacs with full access to its internals could be lots of fun too.
</p>

<p>
A <i>lot</i> of people have experimented with voice input for Emacs over the years. It could be fun to pick up ideas for commands and grammars. Some examples:
</p>

<ul class="org-ul">
<li><a href="https://www.youtube.com/watch?v=8SkdfdXWYaI">Using Python to Code by Voice - YouTube</a> (2013)</li>
<li><a href="https://github.com/jgarvin/mandimus">jgarvin/mandimus: Use speech recognition to command your computer and Emacs. · GitHub</a></li>
<li><a href="https://github.com/ErikPrantare/cursorfree.el">ErikPrantare/cursorfree.el: Edit and navigate from anywhere in the buffer · GitHub</a></li>
<li><a href="https://git.sr.ht/~lepisma/emacs-speech-input/tree/master/item/README.org">~lepisma/emacs-speech-input</a> - uses the idea of a voice cursor, uses an LLM to execute editing instructions</li>
</ul>

<p>
<b>What about automating myself out of this loop?</b> I've considered training a classifier or sending the list to a large language model to categorize links in order to set more reasonable defaults, but I think I'd still want manual control, since the fun is in getting a sense of all the cool things that people are tinkering around with in the Emacs community. I found that with voice control, it was easier for me to say the category than to look for the category it suggested and then say "Okay" to accept the default. If I display the suggested category in a buffer with very large text (and possibly category-specific background colours), then I can quickly glance at it or use my peripheral vision. But yeah, it's probably easier to look at a page and say "Org Mode" than to look at the page, look at the default text, see if it matches Org Mode, and then say okay if it is.
</p>
</div>
</div>
<div id="outline-container-categorizing-emacs-news-items-by-voice-in-org-mode-ideas-for-next-steps" class="outline-3">
<h3 id="categorizing-emacs-news-items-by-voice-in-org-mode-ideas-for-next-steps">Ideas for next steps</h3>
<div class="outline-text-3" id="text-categorizing-emacs-news-items-by-voice-in-org-mode-ideas-for-next-steps">
<p>
I wonder how to line up several categories. I could probably rattle off a few without waiting for the next one to load, and just pause when I'm not sure. Maybe while there's a reasonably good match within the first 1-3 words, I'll take candidates from the front of the queue. Or I could delimit it with another easily-recognized word, like "next".
</p>

<p>
I want to make a more synchronous version of this idea so that I can have a speech-enabled drop-in replacement that I can use as my <code>y-or-n-p</code> while still being able to type <code>y</code> or <code>n</code>. This probably involves using <code>sit-for</code> and polling to see if it's done. And then I can use that to play Twenty Questions, but also to do more serious stuff. It would also be nice to have replacements for <code>read-string</code> and <code>completing-read</code>, since those block Emacs until the user enters something.
</p>

<p>
I might take a side-trip into a conversational interface for M-x doctor and M-x dunnet, because why not. Naturally, it also makes sense to voice-enable <a href="https://github.com/xenodium/agent-shell">agent-shell</a> and <a href="https://github.com/karthink/gptel">gptel</a> interactions.
</p>

<p>
I'd like to figure out a number- or word-based completion mechanism so that I can control Reddit link replacement as well, since I want to select from a list of links from the page. Maybe something similar to the way <a href="https://github.com/jcaw/voicemacs">voicemacs adds numbers to helm and company</a> or how <a href="http://www.cb1.com/~john/computing/emacs/handsfree/flexi-choose.html">flexi-choose.el</a> works.
</p>

<p>
I'm also thinking about how I can shift seamlessly between typing and speaking, like when I want to edit a link title. Maybe I can check if I'm in the minibuffer and what kind of minibuffer I'm in, perhaps like the way <a href="https://github.com/oantolin/embark">Embark</a> does.
</p>

<p>
It would be really cool to define speech commands by reusing the keymap structure that menus also use. This is how to <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Easy-Menu.html">define a menu</a> in Emacs Lisp:
</p>


<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span class="org-keyword">easy-menu-define</span> words-menu global-map
  <span class="org-doc">"Menu for word navigation commands."</span>
  <span class="org-highlight-quoted-quote">'</span>(<span class="org-string">"Words"</span>
     [<span class="org-string">"Forward word"</span> forward-word]
     [<span class="org-string">"Backward word"</span> backward-word]))
</code></pre>
</div>


<p>
and this is how to <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Modifying-Menus.html">set just one binding</a>:
</p>


<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(keymap-set-after my-menu <span class="org-string">"&lt;drink&gt;"</span>
  <span class="org-highlight-quoted-quote">'</span>(<span class="org-string">"Drink"</span> . drink-command) <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">eat</span>)
</code></pre>
</div>


<p>
That makes sense to reuse for speech commands. I'd also like to be able to specify aliases while hiding them or collapsing them for a "What can I say" help view&hellip; Also, if keymaps work, then maybe minor modes or transient maps could work? This sort of feels like it should be the voice equivalent of a transient map.
</p>
</div>
</div>
<div id="outline-container-categorizing-emacs-news-items-by-voice-in-org-mode-the-code-so-far" class="outline-3">
<h3 id="categorizing-emacs-news-items-by-voice-in-org-mode-the-code-so-far">The code so far</h3>
<div class="outline-text-3" id="text-categorizing-emacs-news-items-by-voice-in-org-mode-the-code-so-far">

<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span class="org-keyword">defun</span> <span class="org-function-name">my-emacs-news-categorize-with-voice</span> (<span class="org-type">&amp;optional</span> skip-browse)
  (<span class="org-keyword">interactive</span> (list current-prefix-arg))
  (<span class="org-keyword">unless</span> skip-browse
    (my-spookfox-browse))
  (speech-input-cancel-recording)
  (<span class="org-keyword">let</span> ((default (<span class="org-keyword">if</span> (fboundp <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">my-emacs-news-guess-category</span>) (my-emacs-news-guess-category))))
    (speech-input-from-list
     (<span class="org-keyword">if</span> default
         (format <span class="org-string">"Category (%s): "</span> default)
       <span class="org-string">"Category: "</span>)
     <span class="org-highlight-quoted-quote">'</span>((<span class="org-string">"Org Mode"</span> <span class="org-string">"Org"</span> <span class="org-string">"Org Mode"</span>)
       <span class="org-string">"Other"</span>
       <span class="org-string">"Emacs Lisp"</span>
       <span class="org-string">"Coding"</span>
       (<span class="org-string">"Emacs configuration"</span> <span class="org-string">"Config"</span> <span class="org-string">"Configuration"</span>)
       (<span class="org-string">"Appearance"</span> <span class="org-string">"Appearance"</span>)
       (<span class="org-string">"Default"</span> <span class="org-string">"Okay"</span> <span class="org-string">"Default"</span>)
       <span class="org-string">"Community"</span>
       <span class="org-string">"AI"</span>
       <span class="org-string">"Writing"</span>
       (<span class="org-string">"Reddit"</span> <span class="org-string">"Read it"</span> <span class="org-string">"Reddit"</span>)
       <span class="org-string">"Shells"</span>
       <span class="org-string">"Navigation"</span>
       <span class="org-string">"Fun"</span>
       (<span class="org-string">"Dired"</span> <span class="org-string">"Directory"</span> <span class="org-string">"Dir ed"</span>)
       (<span class="org-string">"Mail, news, and chat"</span> <span class="org-string">"News"</span> <span class="org-string">"Mail"</span> <span class="org-string">"Chat"</span>)
       <span class="org-string">"Multimedia"</span>
       <span class="org-string">"Scroll down"</span>
       <span class="org-string">"Scroll up"</span>
       <span class="org-string">"Web"</span>
       <span class="org-string">"Delete"</span>
       <span class="org-string">"Skip"</span>
       <span class="org-string">"Undo"</span>
       (<span class="org-string">"Quit"</span> <span class="org-string">"Quit"</span> <span class="org-string">"Cancel"</span> <span class="org-string">"All done"</span>))
     (<span class="org-keyword">lambda</span> (result text)
       (message <span class="org-string">"Recognized %s original %s"</span> result text)
       (<span class="org-keyword">pcase</span> result
         (<span class="org-string">"Undo"</span>
          (undo)
          (my-emacs-news-categorize-with-voice t))
         (<span class="org-string">"Skip"</span>
          (forward-line)
          (my-emacs-news-categorize-with-voice))
         (<span class="org-string">"Quit"</span>
          (message <span class="org-string">"All done."</span>)
          (speech-input-cancel-recording))
         (<span class="org-string">"Reddit"</span>
          (my-emacs-news-replace-reddit-link)
          (my-emacs-news-categorize-with-voice t))
         (<span class="org-string">"Scroll down"</span>
          (my-spookfox-scroll-down)
          (my-emacs-news-categorize-with-voice t))
         (<span class="org-string">"Scroll up"</span>
          (my-spookfox-scroll-up)
          (my-emacs-news-categorize-with-voice t))
         (<span class="org-string">"Delete"</span>
          (delete-line)
          (undo-boundary)
          (my-emacs-news-categorize-with-voice))
         (<span class="org-string">"Default"</span>
          (my-org-move-current-item-to-category
           (concat default <span class="org-string">":"</span>))
          (undo-boundary)
          (my-emacs-news-categorize-with-voice))
         (_
          (my-org-move-current-item-to-category
           (concat result <span class="org-string">":"</span>))
          (undo-boundary)
          (my-emacs-news-categorize-with-voice))))
     t)))
</code></pre>
</div>


<p>
It uses <a href="https://sachachua.com/dotemacs#spookfox">Spookfox to control Firefox from Emacs</a>:
</p>

<p>

</p><div class="org-src-container">
<pre class="src src-emacs-lisp" id="org22d90d7"><code>(<span class="org-keyword">defun</span> <span class="org-function-name">my-spookfox-scroll-down</span> ()
  (<span class="org-keyword">interactive</span>)
  (spookfox-js-injection-eval-in-active-tab <span class="org-string">"window.scrollBy(0, document.documentElement.clientHeight);"</span> t))

(<span class="org-keyword">defun</span> <span class="org-function-name">my-spookfox-scroll-up</span> ()
  (<span class="org-keyword">interactive</span>)
  (spookfox-js-injection-eval-in-active-tab <span class="org-string">"window.scrollBy(0, -document.documentElement.clientHeight);"</span>))
</code></pre>
</div>


<p></p>

<p>

</p><div class="org-src-container">
<pre class="src src-emacs-lisp" id="orga82aa0d"><code>(<span class="org-keyword">defun</span> <span class="org-function-name">my-spookfox-background-tab</span> (url <span class="org-type">&amp;rest</span> args)
  <span class="org-doc">"Open URL as a background tab."</span>
  (<span class="org-keyword">if</span> spookfox&#45;&#45;connected-clients
      (spookfox-tabs&#45;&#45;request (cl-first spookfox&#45;&#45;connected-clients) <span class="org-string">"OPEN_TAB"</span> <span class="org-highlight-quoted-quote">`</span>(<span class="org-builtin">:url</span> ,url))
    (browse-url url)))
</code></pre>
</div>


<p></p>

<p>
It also uses these functions for <a href="https://sachachua.com/dotemacs#digital-index-piles-with-emacs">categorizing Org Mode items</a>:
</p>

<p>

</p><div class="org-src-container">
<pre class="src src-emacs-lisp" id="org955687d"><code>(<span class="org-keyword">defun</span> <span class="org-function-name">my-org-move-current-item-to-category</span> (category)
    <span class="org-doc">"Move current list item under CATEGORY earlier in the list.</span>
<span class="org-doc">  CATEGORY can be a string or a list of the form (text indent regexp).</span>
<span class="org-doc">  Point should be on the next line to process, even if a new category</span>
<span class="org-doc">  has been inserted."</span>
    (<span class="org-keyword">interactive</span> (list (completing-read <span class="org-string">"Category: "</span> (my-org-get-list-categories))))
    (<span class="org-keyword">when</span> category
      (<span class="org-keyword">let*</span> ((col (current-column))
             (item (point-at-bol))
             (struct (org-list-struct))
             (category-text (<span class="org-keyword">if</span> (stringp category) category (elt category 0)))
             (category-indent (<span class="org-keyword">if</span> (stringp category) 2 (+ 2 (elt category 1))))
             (category-regexp (<span class="org-keyword">if</span> (stringp category) category (elt category 2)))
             (end (elt (car (last struct)) 6))
             (pos (point))
             s)
        (<span class="org-keyword">setq</span> s (org-remove-indentation (buffer-substring-no-properties item (org-list-get-item-end item struct))))
        (<span class="org-keyword">save-excursion</span>
          (<span class="org-keyword">if</span> (string= category-text <span class="org-string">"x"</span>)
              (org-list-send-item item <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">delete</span> struct)
            (goto-char (caar struct))
            (<span class="org-keyword">if</span> (re-search-forward (concat <span class="org-string">"^ *- +"</span> category-regexp) end t)
                (<span class="org-keyword">progn</span>
                  <span class="org-comment-delimiter">;; </span><span class="org-comment">needs a patch to ol.el to check if stringp</span>
                  (org-list-send-item item (point-at-bol) struct)
                  (org-move-item-down)
                  (org-indent-item))
              (goto-char end)
              (org-list-insert-item
               (point-at-bol)
               struct (org-list-prevs-alist struct))
              (<span class="org-keyword">let</span> ((old-struct (copy-tree struct)))
                (org-list-set-ind (point-at-bol) struct 0)
                (org-list-struct-fix-bul struct (org-list-prevs-alist struct))
                (org-list-struct-apply-struct struct old-struct))
              (goto-char (point-at-eol))
              (insert category-text)
              (org-list-send-item item <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">end</span> struct)
              (org-indent-item)
              (org-indent-item))
            (recenter))))))

(<span class="org-keyword">defun</span> <span class="org-function-name">my-org-guess-list-category</span> (<span class="org-type">&amp;optional</span> categories)
  (<span class="org-keyword">interactive</span>)
  (<span class="org-keyword">require</span> <span class="org-highlight-quoted-quote">'</span><span class="org-constant">cl-lib</span>)
  (<span class="org-keyword">unless</span> categories
    (<span class="org-keyword">setq</span> categories
          (my-helm-org-list-categories-init-candidates)))
  (<span class="org-keyword">let*</span> ((beg (line-beginning-position))
         (end (line-end-position))
         (string (buffer-substring-no-properties beg end))
         (found
          (cl-member string
                     categories
                     <span class="org-builtin">:test</span>
                     (<span class="org-keyword">lambda</span> (string cat-entry)
                       (<span class="org-keyword">unless</span> (string= (car cat-entry) <span class="org-string">"x"</span>)
                         (string-match (regexp-quote (downcase (car cat-entry)))
                                       string))))))
    (<span class="org-keyword">when</span> (car found)
      (my-org-move-current-item-to-category
       (cdr (car found)))
      t)))
</code></pre>
</div>


<p></p>

<p>
For the <code>speech-input</code> functions, experimental code is at <a href="https://codeberg.org/sachac/speech-input">https://codeberg.org/sachac/speech-input</a> .
</p>
</div>
</div>
<div><a href="https://sachachua.com/blog/2026/03/categorizing-emacs-news-items-by-voice-in-org-mode/index.org">View Org source for this post</a></div><p>You can <a href="https://social.sachachua.com/@sacha/statuses/01KMER8FH7NZT56ENT0NHE36Q0" target="_blank" rel="noopener noreferrer">comment on Mastodon</a> or <a href="mailto:sacha@sachachua.com?subject=Comment%20on%20https%3A%2F%2Fsachachua.com%2Fblog%2F2026%2F03%2Fcategorizing-emacs-news-items-by-voice-in-org-mode%2F&body=Name%20you%20want%20to%20be%20credited%20by%20(if%20any)%3A%20%0AMessage%3A%20%0ACan%20I%20share%20your%20comment%20so%20other%20people%20can%20learn%20from%20it%3F%20Yes%2FNo%0A">e-mail me at sacha@sachachua.com</a>.</p>]]></content>
		</entry><entry>
		<title type="html">Expanding yasnippets by voice in Emacs and other applications</title>
		<link rel="alternate" type="text/html" href="https://sachachua.com/blog/2026/03/expanding-yasnippet-by-voice/"/>
		<author><name><![CDATA[Sacha Chua]]></name></author>
		<updated>2026-03-04T16:17:40Z</updated>
    <published>2026-03-04T16:17:40Z</published>
    <category term="emacs" />
<category term="audio" />
<category term="speech-recognition" />
		<id>https://sachachua.com/blog/2026/03/expanding-yasnippet-by-voice/</id>
		<content type="html"><![CDATA[<p>
<a href="https://github.com/joaotavora/yasnippet">Yasnippet</a> is a template system for Emacs. I want to use it by voice. I'd like to be able to say things like "Okay, define interactive function" and have that expand to a matching snippet in Emacs or other applications. Here's a quick demonstration of expanding simple snippets:
</p>

<div class="media-post" id="org7591a42">
<p>
</p><figure><video controls="1" src="https://sachachua.com/blog/2026/03/expanding-yasnippet-by-voice/2026-03-04_12.33.19.webm" type="video/webm"><track kind="subtitles" label="Captions" src="https://sachachua.com/blog/2026/03/expanding-yasnippet-by-voice/2026-03-04_12.33.19.vtt" srclang="en" default=""><a href="https://sachachua.com/blog/2026/03/expanding-yasnippet-by-voice/2026-03-04_12.33.19.webm">Download the video</a></video><figcaption><div>Screencast of expanding snippets by voice in Emacs and in other applications</div></figcaption></figure>
<p></p>

<details class="code-details" style="padding: 1em;
                 border-radius: 15px;
                 font-size: 0.9em;
                 box-shadow: 0.05em 0.1em 5px 0.01em  #00000057;">
                  <summary><strong>Transcript</strong></summary>
<ul class="org-ul">
<li><span class="media-time" data-start="0.000">00:00</span> So I've defined some yasnippets with names that I can say. Here, for example, in this menu, you can see I've got "define interactive function" and "with a buffer that I'll display." And in fundamental mode, I have some other things too. Let's give it a try.</li>
<li><span class="media-time" data-start="19.000">00:19</span> I press my shortcut. "Okay, define an interactive function." You can see that this is a yasnippet. Tab navigation still works.</li>
<li><span class="media-time" data-start="33.000">00:33</span> I can say, "OK, with a buffer that I'll display," and it expands that also.</li>
<li><span class="media-time" data-start="45.000">00:45</span> I can expand snippets in other applications as well, thanks to a global keyboard shortcut.</li>
<li><span class="media-time" data-start="50.000">00:50</span> Here, for example, I can say, "OK, my email." It inserts my email address.</li>
<li><span class="media-time" data-start="62.000">01:02</span> Yasnippet definitions can also execute Emacs Lisp. So I can say, "OK, date today," and have that evaluated to the actual date.</li>
<li><span class="media-time" data-start="81.000">01:21</span> So that's an example of using voice to expand snippets.</li>
</ul>


</details>

</div>

<p>
This is handled by the following code:
</p>


<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span class="org-keyword">defun</span> <span class="org-function-name">my-whisper-maybe-expand-snippet</span> (text)
  <span class="org-doc">"Add to `</span><span class="org-doc"><span class="org-constant">whisper-insert-text-at-point</span></span><span class="org-doc">'."</span>
  (<span class="org-keyword">if</span> (<span class="org-keyword">and</span> text
           (string-match
            <span class="org-string">"^ok</span><span class="org-string"><span class="org-regexp-grouping-backslash">\\</span></span><span class="org-string"><span class="org-regexp-grouping-construct">(?:</span></span><span class="org-string">ay</span><span class="org-string"><span class="org-regexp-grouping-backslash">\\</span></span><span class="org-string"><span class="org-regexp-grouping-construct">)</span></span><span class="org-string">?[,\\.]? </span><span class="org-string"><span class="org-regexp-grouping-backslash">\\</span></span><span class="org-string"><span class="org-regexp-grouping-construct">(</span></span><span class="org-string">.+</span><span class="org-string"><span class="org-regexp-grouping-backslash">\\</span></span><span class="org-string"><span class="org-regexp-grouping-construct">)</span></span><span class="org-string">"</span> text))
    (<span class="org-keyword">let*</span> ((name
            (downcase
             (string-trim
              (replace-regexp-in-string <span class="org-string">"[,\\.]"</span> <span class="org-string">""</span> (match-string 1 text)))))
           (matching
            (seq-find (<span class="org-keyword">lambda</span> (o)
                        (subed-word-data-compare-normalized-string-distance
                         name
                         (downcase (yas&#45;&#45;template-name o))))
                      (yas&#45;&#45;all-templates (yas&#45;&#45;get-snippet-tables)))))
      (<span class="org-keyword">if</span> matching
          (<span class="org-keyword">progn</span>
            (<span class="org-keyword">if</span> (frame-focus-state)
                (<span class="org-keyword">progn</span>
                  (yas-expand-snippet matching)
                  nil)
              <span class="org-comment-delimiter">;; </span><span class="org-comment">In another application</span>
              (<span class="org-keyword">with-temp-buffer</span>
                (yas-minor-mode)
                (yas-expand-snippet matching)
                (buffer-string))))
        text))
    text))
</code></pre>
</div>


<p>
This code relies on <a href="https://github.com/sachac/whisper.el/">my fork of whisper.el</a>, which lets me specify a list of functions for <code>whisper-insert-text-at-point</code>. (I haven't asked for upstream review yet because I'm still testing things, and I don't know if it actually works for anyone else yet.) It does approximate matching on the snippet name using a function from <a href="https://github.com/sachac/subed/blob/main/subed/subed-word-data.el">subed-word-data.el</a> which just uses <code>string-distance</code>. I could probably duplicate the function in my config, but then I'd have to update it in two places if I come up with more ideas.
</p>

<p>
The code for inserting into other functions is defined in <a href="https://sachachua.com/blog/2026/01/using-whisper-el-to-capture-text-to-speech-in-emacs/#multimedia-whisper">my-whisper-maybe-type</a>, which is very simple:
</p>

<p>

</p><div class="org-src-container">
<pre class="src src-emacs-lisp" id="org3c4a075"><code>(<span class="org-keyword">defun</span> <span class="org-function-name">my-whisper-maybe-type</span> (text)
  <span class="org-doc">"If Emacs is not the focused app, simulate typing TEXT.</span>
<span class="org-doc">Add this function to `</span><span class="org-doc"><span class="org-constant">whisper-insert-text-at-point</span></span><span class="org-doc">'."</span>
  (<span class="org-keyword">when</span> text
    (<span class="org-keyword">if</span> (frame-focus-state)
        text
      (make-process <span class="org-builtin">:name</span> <span class="org-string">"xdotool"</span> <span class="org-builtin">:command</span>
                    (list <span class="org-string">"xdotool"</span> <span class="org-string">"type"</span>
                          text))
      nil)))
</code></pre>
</div>


<p></p>

<p>
Someday I'd like to provide alternative names for snippets. I also want to make it easy to fill in snippet fields by voice. I'd love to be able to answer minibuffer questions from <code>yas-choose-value</code>, <code>yas-completing-read</code>, and other functions by voice too. Could be fun!
</p>

<p>
Related:
</p>

<ul class="org-ul">
<li><a href="https://github.com/sachac/snippets">My snippets repository</a></li>
<li><a href="https://sachachua.com/topic/speech-recognition/">My topic page for speech recognition</a></li>
</ul>

<div class="note">This is part of my <a href="https://sachachua.com/dotemacs#writing-and-editing-speech-recognition-expanding-yasnippet-by-voice">Emacs configuration.</a></div><div><a href="https://sachachua.com/blog/2026/03/expanding-yasnippet-by-voice/index.org">View Org source for this post</a></div><p>You can <a href="mailto:sacha@sachachua.com?subject=Comment%20on%20https%3A%2F%2Fsachachua.com%2Fblog%2F2026%2F03%2Fexpanding-yasnippet-by-voice%2F&body=Name%20you%20want%20to%20be%20credited%20by%20(if%20any)%3A%20%0AMessage%3A%20%0ACan%20I%20share%20your%20comment%20so%20other%20people%20can%20learn%20from%20it%3F%20Yes%2FNo%0A">e-mail me at sacha@sachachua.com</a>.</p>]]></content>
		</entry><entry>
		<title type="html">Using speech recognition for on-the-fly translations in Emacs and faking in-buffer completion for the results</title>
		<link rel="alternate" type="text/html" href="https://sachachua.com/blog/2026/02/using-speech-recognition-for-on-the-fly-translations-in-emacs-and-faking-in-buffer-completion-for-the-results/"/>
		<author><name><![CDATA[Sacha Chua]]></name></author>
		<updated>2026-03-31T16:31:15Z</updated>
    <published>2026-02-27T20:11:58Z</published>
    <category term="audio" />
<category term="speech-recognition" />
<category term="emacs" />
<category term="speech" />
		<id>https://sachachua.com/blog/2026/02/using-speech-recognition-for-on-the-fly-translations-in-emacs-and-faking-in-buffer-completion-for-the-results/</id>
		<content type="html"><![CDATA[<div class="update" id="orgeabb215">
<p>
<span class="timestamp-wrapper"><time class="timestamp" datetime="2026-03-31">[2026-03-31 Tue]</time></span>: I added the recognized text so that I can confirm what was translated. I also moved my-type-with-hint to <a href="https://codeberg.org/sachac/learn-lang/src/branch/main/learn-lang-type.el">learn-lang-type-with-hint</a>.
</p>

</div>

<p>
When I'm writing a journal entry in French, I
sometimes want to translate a phrase that I can't
look up word by word using a dictionary.
Instead of switching to a browser, I can use an
Emacs function to prompt me for text and either
insert or display the translation.
The <a href="https://github.com/alphapapa/plz.el">plz</a> library makes HTTP requests slightly
neater.
</p>


<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span class="org-keyword">defun</span> <span class="org-function-name">my-lang-en-to-fr</span> (text <span class="org-type">&amp;optional</span> display-only)
  (<span class="org-keyword">interactive</span> (list (read-string <span class="org-string">"Text: "</span>) current-prefix-arg))
  (<span class="org-keyword">let*</span> ((url <span class="org-string">"https://translation.googleapis.com/language/translate/v2"</span>)
         (params <span class="org-highlight-quoted-quote">`</span>((<span class="org-string">"key"</span> . ,(getenv <span class="org-string">"GOOGLE_API_KEY"</span>))
                   (<span class="org-string">"q"</span> . ,text)
                   (<span class="org-string">"source"</span> . <span class="org-string">"en"</span>)
                   (<span class="org-string">"target"</span> . <span class="org-string">"fr"</span>)
                   (<span class="org-string">"format"</span> . <span class="org-string">"text"</span>)))
         (query-string (mapconcat
                        (<span class="org-keyword">lambda</span> (pair)
                          (format <span class="org-string">"%s=%s"</span>
                                  (url-hexify-string (car pair))
                                  (url-hexify-string (cdr pair))))
                        params
                        <span class="org-string">"&amp;"</span>))
         (full-url (concat url <span class="org-string">"?"</span> query-string)))
    (<span class="org-keyword">let*</span> ((response (plz <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">get</span> full-url <span class="org-builtin">:as</span> <span class="org-highlight-quoted-quote">#'</span><span class="org-highlight-quoted-symbol">json-read</span>))
           (data (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">data</span> response))
           (translations (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">translations</span> data))
           (first-translation (car translations))
           (translated-text (alist-get <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">translatedText</span> first-translation)))
      (<span class="org-keyword">when</span> (called-interactively-p <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">any</span>)
        (<span class="org-keyword">if</span> display-only
            (message <span class="org-string">"%s"</span> translated-text)
          (insert translated-text)))
      translated-text)))
</code></pre>
</div>


<p>
I think it would be even nicer if I could use speech synthesis, so I can keep it a little more separate from my typing thoughts. I want to be able to say "Okay, translate &hellip;" or "Okay, &hellip; in French" to get a translation. I've been using <a href="https://github.com/sachac/whisper.el/">my fork of natrys/whisper.el</a> for <a href="https://sachachua.com/topic/speech-recognition/">speech recognition</a> in English, and I like it a lot. By adding a function to <code>whisper-after-transcription-hook</code>, I can modify the intermediate results before they're inserted into the buffer.
</p>


<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span class="org-keyword">defun</span> <span class="org-function-name">my-whisper-translate</span> ()
  (goto-char (point-min))
  (<span class="org-keyword">let</span> ((case-fold-search t))
    (<span class="org-keyword">when</span> (re-search-forward <span class="org-string">"okay[,\\.]? translate[,\\.]? </span><span class="org-string"><span class="org-regexp-grouping-backslash">\\</span></span><span class="org-string"><span class="org-regexp-grouping-construct">(</span></span><span class="org-string">.+</span><span class="org-string"><span class="org-regexp-grouping-backslash">\\</span></span><span class="org-string"><span class="org-regexp-grouping-construct">)</span></span><span class="org-string"><span class="org-regexp-grouping-backslash">\\</span></span><span class="org-string"><span class="org-regexp-grouping-construct">|</span></span><span class="org-string">okay[,\\.]? </span><span class="org-string"><span class="org-regexp-grouping-backslash">\\</span></span><span class="org-string"><span class="org-regexp-grouping-construct">(</span></span><span class="org-string">.+?</span><span class="org-string"><span class="org-regexp-grouping-backslash">\\</span></span><span class="org-string"><span class="org-regexp-grouping-construct">)</span></span><span class="org-string"> in French"</span> nil t)
      (<span class="org-keyword">let*</span> ((s (<span class="org-keyword">or</span> (match-string 1) (match-string 2)))
             (translation (<span class="org-keyword">save-match-data</span> (my-lang-en-to-fr s))))
        (replace-match
         (propertize translation
                     <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">type-hint</span> translation
                     <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">type-original</span> s
                     <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">help-echo</span> s))))))

(<span class="org-keyword">with-eval-after-load</span> <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">whisper</span>
  (add-hook <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">whisper-after-transcription-hook</span> <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">my-whisper-translate</span> 70))
</code></pre>
</div>


<p>
But that's too easy. I want to actually type things myself so that I get more practice. Something like an autocomplete suggestion would be handy as a way of showing me a hint at the cursor. The usual completion-at-point functions are too eager to insert things if there's only one candidate, so we'll just fake it with an overlay. This code works only with my whisper.el fork because it supports using a list of functions for <code>whisper-insert-text-at-point</code>.
</p>


<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span class="org-keyword">defun</span> <span class="org-function-name">my-whisper-maybe-type-with-hints</span> (text)
  <span class="org-doc">"Add this function to `</span><span class="org-doc"><span class="org-constant">whisper-insert-text-at-point</span></span><span class="org-doc">'."</span>
  (<span class="org-keyword">let*</span> ((hint (<span class="org-keyword">and</span> text (org-find-text-property-in-string <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">type-hint</span> text)))
         (original (<span class="org-keyword">and</span> text (org-find-text-property-in-string <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">type-original</span> text))))
    (<span class="org-keyword">if</span> hint
        (<span class="org-keyword">progn</span>
          (learn-lang-type-with-hint hint original)
          nil)
      text)))
</code></pre>
</div>


<p>
Here's a demonstration of me saying "Okay, this is a test, in French.":
</p>

<div class="media-post" id="orgdf2cbf2">
<p>
</p><figure><video controls="1" src="https://sachachua.com/blog/2026/02/using-speech-recognition-for-on-the-fly-translations-in-emacs-and-faking-in-buffer-completion-for-the-results/2026-02-27-translate-and-type-with-hints.webm" type="video/webm"><a href="https://sachachua.com/blog/2026/02/using-speech-recognition-for-on-the-fly-translations-in-emacs-and-faking-in-buffer-completion-for-the-results/2026-02-27-translate-and-type-with-hints.webm">Download the video</a></video><figcaption><div>Screencast of using speech recognition to translate into French and provide a hint when typing</div></figcaption></figure>
<p></p>

</div>

<p>
Since we're faking in-buffer completion here, maybe we can still get away with considering this as an entry for <a href="https://sachachua.com/blog/2026/01/emacs-carnival-february-2026-completion/">Emacs Carnival February 2026: Completion</a> ? =)</p>

<div class="note">This is part of my <a href="https://sachachua.com/dotemacs#writing-and-editing-speech-recognition-using-speech-recognition-for-translations-in-emacs-and-faking-in-buffer-completion-for-the-results">Emacs configuration.</a></div><div><a href="https://sachachua.com/blog/2026/02/using-speech-recognition-for-on-the-fly-translations-in-emacs-and-faking-in-buffer-completion-for-the-results/index.org">View Org source for this post</a></div><p>You can <a href="mailto:sacha@sachachua.com?subject=Comment%20on%20https%3A%2F%2Fsachachua.com%2Fblog%2F2026%2F02%2Fusing-speech-recognition-for-on-the-fly-translations-in-emacs-and-faking-in-buffer-completion-for-the-results%2F&body=Name%20you%20want%20to%20be%20credited%20by%20(if%20any)%3A%20%0AMessage%3A%20%0ACan%20I%20share%20your%20comment%20so%20other%20people%20can%20learn%20from%20it%3F%20Yes%2FNo%0A">e-mail me at sacha@sachachua.com</a>.</p>]]></content>
		</entry><entry>
		<title type="html">Using Silero voice activity detection to automatically queue multiple transcriptions with natrys/whisper.el</title>
		<link rel="alternate" type="text/html" href="https://sachachua.com/blog/2026/01/using-silero-voice-activity-detection-to-automatically-queue-multiple-transcriptions-with-natrys-whisper-el/"/>
		<author><name><![CDATA[Sacha Chua]]></name></author>
		<updated>2026-03-27T23:03:01Z</updated>
    <published>2026-01-29T16:24:46Z</published>
    <category term="audio" />
<category term="speech-recognition" />
<category term="emacs" />
		<id>https://sachachua.com/blog/2026/01/using-silero-voice-activity-detection-to-automatically-queue-multiple-transcriptions-with-natrys-whisper-el/</id>
		<content type="html"><![CDATA[<div class="update" id="org67634b7">
<p>
<span class="timestamp-wrapper"><time class="timestamp" datetime="2026-03-27">[2026-03-27 Fri]</time></span>: Moved code to <a href="https://codeberg.org/sachac/speech-input">sachac/speech-input</a>.
</p>

</div>

<p>
I can <a href="https://sachachua.com/blog/2026/01/queue-multiple-transcriptions-with-whisper-el-speech-recognition/">queue multiple transcriptions with whisper.el</a> so that they get processed sequentially with backup audio. It catches up when I pause to think. Now I want to use <a href="https://pytorch.org/hub/snakers4_silero-vad_vad/">Silero voice activity detection</a> to do that kind of segmentation for me automatically.
</p>

<p>
First, I need a Python server that can print out events when it notices the start or stop of a speech segment. If I print out the timestamps, I might be able to cross-reference it someday with interestingthings. For now, even just paying attention to the end of a segment is enough for what I want to do.
</p>

<details class="code-details" style="padding: 1em;
                 border-radius: 15px;
                 font-size: 0.9em;
                 box-shadow: 0.05em 0.1em 5px 0.01em  #00000057;">
                  <summary><strong>Python script for printing out events</strong></summary>

<div class="org-src-container">
<pre class="src src-python"><code><span class="org-keyword">import</span> sounddevice <span class="org-keyword">as</span> sd
<span class="org-keyword">import</span> numpy <span class="org-keyword">as</span> np
<span class="org-keyword">import</span> torch
<span class="org-keyword">import</span> sys
<span class="org-keyword">from</span> datetime <span class="org-keyword">import</span> datetime, timedelta

<span class="org-variable-name">SILENCE_DURATION</span> <span class="org-operator">=</span> 500
<span class="org-variable-name">SAMPLING_RATE</span> <span class="org-operator">=</span> 16000
<span class="org-variable-name">CHUNK_SIZE</span> <span class="org-operator">=</span> 512
<span class="org-variable-name">model</span>, <span class="org-variable-name">utils</span> <span class="org-operator">=</span> torch.hub.load(repo_or_dir<span class="org-operator">=</span><span class="org-string">'snakers4/silero-vad'</span>,
                              model<span class="org-operator">=</span><span class="org-string">'silero_vad'</span>,
                              force_reload<span class="org-operator">=</span><span class="org-constant">False</span>)

(<span class="org-variable-name">get_speech_timestamps</span>, <span class="org-variable-name">save_audio</span>, <span class="org-variable-name">read_audio</span>, <span class="org-variable-name">VADIterator</span>, <span class="org-variable-name">collect_chunks</span>) <span class="org-operator">=</span> utils
<span class="org-variable-name">vad_iterator</span> <span class="org-operator">=</span> VADIterator(model, threshold<span class="org-operator">=</span>0.5, min_silence_duration_ms<span class="org-operator">=</span>SILENCE_DURATION)

<span class="org-variable-name">stream_start_time</span> <span class="org-operator">=</span> <span class="org-constant">None</span>

<span class="org-keyword">def</span> <span class="org-function-name">format_iso_with_offset</span>(offset_seconds):
    <span class="org-keyword">if</span> stream_start_time <span class="org-keyword">is</span> <span class="org-constant">None</span>:
        <span class="org-keyword">return</span> <span class="org-string">"PENDING"</span>
    <span class="org-variable-name">event_time</span> <span class="org-operator">=</span> stream_start_time <span class="org-operator">+</span> timedelta(seconds<span class="org-operator">=</span>offset_seconds)
    <span class="org-keyword">return</span> event_time.astimezone().isoformat(timespec<span class="org-operator">=</span><span class="org-string">'milliseconds'</span>)

<span class="org-keyword">def</span> <span class="org-function-name">audio_callback</span>(indata, frames, time, status):
    <span class="org-keyword">global</span> stream_start_time
    <span class="org-keyword">if</span> status:
        <span class="org-builtin">print</span>(status, file<span class="org-operator">=</span>sys.stderr)
    <span class="org-keyword">if</span> stream_start_time <span class="org-keyword">is</span> <span class="org-constant">None</span>:
        <span class="org-variable-name">stream_start_time</span> <span class="org-operator">=</span> datetime.now()
    <span class="org-variable-name">tensor_input</span> <span class="org-operator">=</span> torch.from_numpy(indata.copy()).flatten()
    <span class="org-variable-name">speech_dict</span> <span class="org-operator">=</span> vad_iterator(tensor_input, return_seconds<span class="org-operator">=</span><span class="org-constant">True</span>)
    <span class="org-keyword">if</span> speech_dict:
        <span class="org-keyword">if</span> <span class="org-string">"start"</span> <span class="org-keyword">in</span> speech_dict:
            <span class="org-builtin">print</span>(f<span class="org-string">"START </span>{format_iso_with_offset(speech_dict['start'])}<span class="org-string">"</span>, flush<span class="org-operator">=</span><span class="org-constant">True</span>)
        <span class="org-keyword">if</span> <span class="org-string">"end"</span> <span class="org-keyword">in</span> speech_dict:
            <span class="org-builtin">print</span>(f<span class="org-string">"END </span>{format_iso_with_offset(speech_dict['end'])}<span class="org-string">"</span>, flush<span class="org-operator">=</span><span class="org-constant">True</span>)
<span class="org-keyword">try</span>:
    <span class="org-keyword">with</span> sd.InputStream(samplerate<span class="org-operator">=</span>SAMPLING_RATE,
                        channels<span class="org-operator">=</span>1,
                        callback<span class="org-operator">=</span>audio_callback,
                        blocksize<span class="org-operator">=</span>CHUNK_SIZE):
        <span class="org-keyword">while</span> <span class="org-constant">True</span>:
            <span class="org-keyword">pass</span>
<span class="org-keyword">except</span> <span class="org-type">KeyboardInterrupt</span>:
    <span class="org-builtin">print</span>(<span class="org-string">"</span><span class="org-constant">\n</span><span class="org-string">Stopping..."</span>)
</code></pre>
</div>



</details>

<p>
I've mode the code to <a href="https://codeberg.org/sachac/speech-input/src/branch/main/speech-input-vad.el">speech-input-vad.el</a>, so now I can use <code>speech-input-vad-start</code> to start monitoring speech events.
</p>


<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span class="org-keyword">use-package</span> speech-input <span class="org-builtin">:load-path</span> <span class="org-string">"~/proj/speech-input/"</span>)
</code></pre>
</div>


<p>
Because I added Pulse properties to the process environment, I can easily use <a href="https://sachachua.com/blog/2026/01/visualizing-and-managing-pipewire-audio-graphs-from-emacs/">epwgraph</a> to rewire the input so that it gets the input from my VirtualMicSink instead of the default system audio device. (Someday I'll figure out how to specify that as the input automatically.)
</p>

<p>
Then I can start this process from Emacs:
</p>


<div class="org-src-container">
<pre class="src src-emacs-lisp"><code>(<span class="org-keyword">with-eval-after-load</span> <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">speech-input-vad</span>
  (add-hook <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">speech-input-vad-on-end-functions</span> <span class="org-highlight-quoted-quote">#'</span><span class="org-highlight-quoted-symbol">my-whisper-maybe-continue</span>))

(<span class="org-keyword">defun</span> <span class="org-function-name">my-whisper-maybe-continue</span> ()
  (<span class="org-keyword">when</span> (process-live-p whisper&#45;&#45;recording-process)
    (my-whisper-continue)))
</code></pre>
</div>


<p>
Now I can press my shortcut for <code>my-whisper-continue</code> to start the process. As I keep talking, it will continue to record. When I pause for more than a second between sentences, then it will send that chunk to the server for transcription without me having to press another button, while still listening for more speech.
</p>

<p>
How is this different from the streaming approach that many real-time speech recognition services offer? I think this gives me a bit more visibility into and control of the process. For my personal use, I don't need to have everything processed as quickly as possible, and I'm not trying to replicate live captions. I just want to be able to look back over the last five minutes to try to remember what I was talking about. I usually have a lot of quiet time as I think through my next steps, and it's fine to have it catch up then. I also like that I can save time-stamped audio files for later processing, divided according to the speech segments. Those might be a little bit easier to work with when I get around to compositing them into a video.
</p>

<div class="note">This is part of my <a href="https://sachachua.com/dotemacs#writing-and-editing-speech-recognition-using-silero-voice-activity-detection-to-automatically-queue-multiple-transcriptions-with-natrys-whisper-el">Emacs configuration.</a></div><div><a href="https://sachachua.com/blog/2026/01/using-silero-voice-activity-detection-to-automatically-queue-multiple-transcriptions-with-natrys-whisper-el/index.org">View Org source for this post</a></div><p>You can <a href="mailto:sacha@sachachua.com?subject=Comment%20on%20https%3A%2F%2Fsachachua.com%2Fblog%2F2026%2F01%2Fusing-silero-voice-activity-detection-to-automatically-queue-multiple-transcriptions-with-natrys-whisper-el%2F&body=Name%20you%20want%20to%20be%20credited%20by%20(if%20any)%3A%20%0AMessage%3A%20%0ACan%20I%20share%20your%20comment%20so%20other%20people%20can%20learn%20from%20it%3F%20Yes%2FNo%0A">e-mail me at sacha@sachachua.com</a>.</p>]]></content>
		</entry>
</feed>