Home > Projects > AnnounceEmail

Background

I have my computer attached to my stereo so I can listen to MP3s through iTunes. The computer is upstairs. When email arrives, Mail.app beeps. I hear this on the speakers downstairs and have to go upstairs to find out who actually sent the mail.

This script uses the built-in "Text to speech" facility in OS X to actually speak an announcement each time I get email, including the name of the sender. As a bonus, it even pauses iTunes before making the announcment (and unpauses afterwards).

I should mention that, in 5 years as a professional programmer, this 150-line Perl script was the first program I ever wrote that impressed my wife.

Requirements

Installation

To install:

  1. Put it in your Library/Scripts directory, or wherever you like.
  2. Add a line like this to your crontab:
    00 *  * * *   /Users/mark/Library/Scripts/say_recent_email_senders.pl
    
    This tells cron to run the script once an hour. During that hour, it will keep running in the background, so once an hour is plenty.
  3. Make the script executable by doing this at the command line command line:
    chmod +x ~/Library/Scripts/say_recent_email_senders.pl
    
  4. If you wish to use an email_names.pl file, you will need to make a lib subdirectory in whichever directory the script itself is stored in, and put the file there.

It will announce any mail that arrives after it is first run, but not any existing unread mail.

If you don't know how to use cron, or you have any other questions about the script, please let me know.

Currently, the script is launched via cron, when it probably should be launched as via OS X's StartupItems. I used cron so that the script could automatically kill itself and relaunch when I modified it, which was useful during the initial development. If enough people start to use the script, I will investigate StartupItems.

To-do

x bug: announces your own sent messages
- bug: turns volume to max, then doesn't reset it
x doc: clarify the crontab setting (every minute not necessary)
x doc: clarify the first-run situation: only mail received after first run will be announced
- feature: read subject line (optionally)
- feature: whitelist/blacklist (names to say or ignore)
x feature: allow override of pronunciation (e.g. 'whitney lyman' => [wit knee lie mun) due to bad voice emulation
- feature: consider triggering via applescript rule rather than cron
- feature: ability to turn off and on
x bug: some mail directories are stored with all messages in a single file.  script does 
	not handle these correctly.