Emacspeak In The Age Of Cloud Computing
1. Executive Summary
Emacspeak has supported Cloud Computing since 1995, i.e., long before the term was invented. I have used Emacs with Emacspeak running on remote servers (called cloud-top in the rest of this article) since that time, with a local speech server on my client machine providing spoken feedback. The underlying ssh-based scripts have changed over time; this article documents what I have been using for the last 7 years or more. As with everything else Linux, you should not use this without understanding how it works. All of the relevant code is checked into GitHub, but if you use it without understanding, you are likely to get 2 for the price of 1๐.
2. The Basics
- Emacspeak produces all spoken and non-spoken feedback via a speech server — see Emacspeak: Beautiful Code for the detailed architecture overview.
- This server runs as a separate process and can either run locally i.e. on the machine running emacs; it can also run remotely, e.g. your laptop from which you login to your cloud-top.
- Note the local and remote terminology in the above — to Emacspeak, the machine where Emacs runs is the local machine, so your machine in the cloud is local to Emacspeak.
- Consequently, the machine from where you SSH to the cloud, a laptop, a Raspberry Pi, or in a future a tin-can that you use as a client is remote to emacspeak.
3. How It Works
- When you start Emacs with Emacspeak loaded, Emacs starts the speech-server as the first step in the emacspeak startup. normally this starts the local server for your prefered TTS engine.
- See the emacspeak manual for how this speech-server is determined.
- When running Emacspeak on a cloud-top, this local speech server is just a simple shell script that connects to a local port — by default 2222.
- When you connect to your cloud-top via SSH, you first reverse port forward port 2222 from the cloud-top back to your client. This causes data sent to port 2222 on the cloud-top by Emacs to show up on port 2222 on the local machine where your speech server is listening.
- With that reverse port forwarding in place and assuming that
espeak
is your TTS engine, running the speech-servercloud-espeak
on the cloud-top connects back to your client to produce spoken output. - For the previous step to work, something (or someone) needs to be listening on port 2222 on your client.
So you need to start the relevant speech server on your client before you
ssh
to your cloud-top — in the case ofespeak
, this isssh-espeak
.See directory
bash-utils
in your emacspeak Git checkout for the relevant Bash scripts.
4. Workflow
Here is what the workflow looks like, again, use this only if you have read and understood the previous section. SeeBash Utils for the scripts mentioned below. Everything below assumes a Bash Shell.
On your cloud-top, specify the speech-server to use by running
export DTK_PROGRAM=cloud-espeak
You can put the above in your .bash_profile
on your cloud-top.
On your client device, run
. <emacspeak_dir>/bash-utils/remote
This need be done only once per interactive shell.It defines bash
functions remote and rtts.
Next, run Bash function remote defined in the script you just loaded.
remote host.example.com speech-server espeak
This does the following:
- Starts a local speech server for the TTS engine
espeak
. - Opens an SSH session to the cloud-top host.example.com.
- Plays a musical chime (using
sox
) to cue completion. - Depending on your SSH setup, you may or may not need to type your ssh password at this point; avoiding having to type a password is beyond the perview of this article, consult the SSH manual pages.
- Now, run Emacs on the cloud-top. Assuming that you have updated your Emacs initialization to load Emacspeak, this will get Emacspeak running on the cloud-top talking on your client.
- Note that typically, you should run something like
screen
on the cloud-top and run Emacs within thatscreen
session; this will let you persist a running Emacs across multiple login/logout.
5. Experience On A Well-Configured Setup
On a well-configured setup, you typically need only do:
- Run the bash function that starts the local TTS server, and then connects to the cloud-top via SSH with reverse-port forwarding active.
- Assuming there is an Emacs session running under screen at the remote end, it'll start talking on your local client.