My iOS apps
Other apps
Open source
  • Bandwidth benchmark
  • RAVM virtual machine
  • Big integer division
  • Prime numbers
  • AntiJOP sanitizer
  • TouchWidgets UI lib
  • Networking utils
  • Documentation
  • x86 instructions ref
  • GIT quick ref
  • GPG quick ref
  • Avoid Ubuntu
  • Android malware risks
  • iOS malware risks
  • OS/X security tips
  • Tor blockers
  • Software engineering
  • BASH aliases
  • I.B. pro/con
  • Why 64-bit?
  • Vocal programming
  • Nutrition
  • Blog
  • Contact
    1 at zsmith dot co

    Practical experience doing computer programming using Dragon Dictate 4

    Revision 7
    © by
    All rights reserved.

    After many months of practical experience writing software using Dragon Dictate 4, here I report my findings.

    0. Why Dragon Dictate?

    Nuance currently produces the most accurate automatic speech recognition (ASR) software. The alternatives, like the speech recognition that's built in to Windows, called Windows Speech Recognition, or CMU Sphinx, make too many errors to be useful for programming.

    Proponents of vocal programming usually advocate the use of the Windows-only product Dragon NaturallySpeaking 12.5, regardless of whether one is programming on Windows, a Mac, or Linux. If you aren't using Windows, DNS and Windows 7 can be run in a virtual machine and a network connection can be made to the host OS. But it requires running Windows 7 (not 8 or later) and Dragon NaturallySpeaking 12.5 (not 13 or later) in the VM. This is because DNS 13 or later are somehow less compatible with the plugin that lets Dragon send all speech to a Python script. And DNS 12.5 does not play well with Windows 8 and later. Using DNS in a VM also necessitates having enough hard drive space for the virtual machine's hard drive (which I don't).

    All this can theoretically be done, and people have done it, but I feel it's a little too elaborate. It makes more sense to just work with the made-for-Mac product from Nuance, Dragon Dictate, and work around its bugginess and defects.

    1. Modes

    Dragon Dictate has several modes. For programming, you will want to use Command Mode all of the time, not the default Dictation Mode.

    Dictation mode is meant for use with Microsoft Word and similar applications used by non-programmers. It has a tendency when interacting with apps other than Word to insert spaces, make the cursor jump around randomly (due to bugginess), and inappropriately upper-case the first letter of words unexpectedly. All of which makes it a messy mode for programming. Using Command Mode obviates these problems.

    You may be thinking, based on the name Command Mode, that it prevents you from entering free-form text like code comments, and variable names. This is not the case. In Command Mode there is no problem entering these, because commands can use a wildcard parameter macro for entering such text. These consist of one or more words followed by a wildcard expression that can be any sequence of English words. (Note: wildcard macros also work in Dictation Mode.)

    I use wildcard macros for entering the following:

    • variable names
    • method and function names
    • literal strings
    • comments in code
    • comments in git commits
    • composing short emails

    For example using my camel macro I can say:

    	camel run background operation 
    and this will enter

    For entering a sentence of text into a comment I might say:

    	sentence this is a test
    and this will enter
    	This is a test.

    The only problem using Command Mode all the time is that when you switch over to a chat program or email, you will typically want to switch Dragon Dictate to Dictation Mode as that works better for anything more than about two sentences.

    2. Macros (commands)

    Entering programming-specific macros using the Dragon command editor window is not too difficult, and I have done quite a lot of it, however it becomes tedious after a while and the command editor occasionally makes mistakes because it is certainly buggy in DD4.

    To solve this, I wrote a C program that automatically generates all of my macros in the form of an XML file in Dragon Dictate's commandtext macro files format. This provides some advantages:

    • It lets me avoid using the Dragon command editor and getting frustrated due to its bugs.
    • It lets me generate large numbers of similar macros e.g. all 676 2-letter combinations.
    • It helps me keep my macros nicely organized by category e.g. cursor movements, Objective C specific macros, command-line operatios etc.
    • I found a way to insert keystrokes from a BASH script, which is cleaner than inserting keystrokes from AppleScript.
    • I can change between different sets of macros for different programming languages efficiently. If, for the next week, I'll be coding in C++ I can tell my C program to only generate macros for that language.
    There are some caveats:
    • As of macOS Sierra, AppleScript is broken and it cannot reliably insert keystrokes into the event loop. The AppleScript project manager coincidentally recently left Apple. This means virtually all of my macros invoke BASH.
    • AppleScript macros have to include a compiled binary blob that DD previously generated. For this reason, I avoid using AppleScript macros.
    • DD4's XML parser seems to have a few bugs so I avoid using keystroke macros and text macros. These do not work in some cases.
    • DD4 is too feeble to support all 17576 of the 3-letter combinations e.g. xyz. That is too many macros for it and loading them causes a crash every time.
    • Note! DD6 is worse and it crashes when I attempt to load more than a few hundred macros.
    • Whenever I change my macros, I have to erase all of the existing macros using a BASH alias and then generate and reload the new ones. This is a simple task.

    Do be aware, you will need to create a macro for every single expression that you will need in programming e.g. int, @property(nonatomic,strong), etc. That may seem like a lot of work, but I have done it and below I provide a link to my macros that anyone can use.

    3. Efficiency

    Assuming that you don't have a sore throat, programming by voice seems to be more efficient than programming by tapping on a keyboard.

    There are several reasons for this:

    1. It is simply faster to say words like double than to type them out.
    2. Programming involves a lot of repetitive typing e.g. think of how many thousands of times you have typed in the various characters to express a new function declaration or definition. With voice input both short and long key sequences are compressible into short macros.
    3. If you have a good keyboard typing can become addictive and it becomes all too easy to type something even though cutting and pasting for another part of your code would have been much less laborious and quicker.


    My program for generating macros for Dragon Dictate is here.

    How to erase all DD macros

    Do this at your own risk! First, excite Dragon Dictate. Then do this in Terminal:
    rm -rf ~/Library/Application\ Support/Dragon/Command*


    The now-famous Tavis Rudd speech:

    © Zack Smith