This is a pro-tip that I picked up from Aaron Lerch - using the
say voice synthesis command after a long-running command-line task. Often times, at work, I'll have to run some sort of compilation process that can take anywhere from a few seconds to a few minutes. And, in order to maximize my productivity, I'll use this compilation "down time" to perform other duties. However, so as to not let myself go down a rabbit hole, I'll append the
say command so that I am alerted to the completion of the compilation.
A few months ago, I took a look at using the Voice Synthesis API in the browser. On the Mac, at least, this API is built on top of the
say command that ships with the Mac OS. The
say command allows us to convert text-to-speech using a variety of voices and pitches (and probably a number of other settings that I've never tried).
So, for example, to get the computer to speak out loud, we could just enter the following command in our terminal window:
say "Oh sweet chickens"
After some trial-and-error, I've found that I enjoy the Fiona voice the most. So, I might write the same command as such:
say --voice Fiona "Oh sweet chickens"
Now, getting back to how this helps me stay productive with long running tasks on the command-line, we can use the
&& operator to run a series of tasks in sequent on the command-line. Which means, I can run the
say command right after my long-running task.
sleep command to simulate a long-running command-line task, I can do something like this:
sleep 3 && say --voice Fiona "Done processing, back to work"
This will sleep the process for 3-seconds and then, upon completion, execute the
say command. And, since I have my headphones in while I work, I'll immediately be alerted to the fact that my long-running task has completed its execution.
To make this easier we can alias the
say command and its arguments:
alias ondone="say --voice Fiona 'Done processing, back to work'"
Which means that I can then simplify the rest of my command-line tasks like this:
sleep 3 && ondone
Having the command-line alert me to the fact that it's done processing is helpful for my productivity because it allows me to switch back-and-forth between mental gestures without overhead. Thanks to Aaron for this hot tip!