Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Speak new Mail notifications via a set of scripts Apps
I like to have my incoming mail subject and sender read to me using the Mac's built-in speech synthesis, so I can decide if I want to drop what I'm doing to read it. Although there are a number of packages available to do just that, most are costly for what should be a simple thing, or don't do it the way I want. The other problem is that many of the mailing lists I'm on insert some gobbledeegook such as "[MailingListName]" in front of the subject, which the speech synthesis engine can't make sense of. I also like certain names in my Address Book to be read in a personalized way, or pronounced differently from how they're written.

So, with the help and suggestions of many hints and forum postings on macosxhints (thanks to everyone who inspired this!), I wrote a set of scripts that do just what I want. Whenever new mail comes in, it gets passed to the main script by a mail rule. The script then turns down iTunes if it's running, so you can hear the announcement -- it turns the iTunes volume back up when it's done. If you tell it to in the preferences, the script will also scan all the senders to see if they are in the Address Book, and use the nickname or the phonetic name (in that order) instead of the sender text. So if the mail sender neglects to put their full name in the mail (e.g. just "joe@mail.com"), their name will still be read correctly if they're in your Address Book.

It will strip out "Re:" and "Fwd:" in front of subjects and say "Reply from..." or "Forward from..." instead. You can also add mailing list names and pronounciations using an auxiliary script. For example, any mail with subject "[JumbledListserv] Check this out!" will be read as "New Jumble mail about 'Check this out!' from...". There are also auxiliary scripts to remove mailing list names and set the prefs.

The first step is to download the scripts [47KB] (macosxhints mirror).

Put the four unzipped scripts directly in your ~/Library/Scripts/Mail Scripts folder. Now make a new rule: Have the SayMailThreaded___ctl-z script activate for any new message. The Set Speak Mail Prefs script obviously sets the prefs. To add a new mailing list to be announced, select a message from the mailing list and run Add Mailing List, (or hit Control-G), and to remove a group, do Remove Mailing Lists (or Control-R). You can run the speaking script on any selected messages to see how it sounds as well -- just choose it from the Mail scripts menu, or hit Control-Z.

Important: You can change the name of any of the scripts (e.g. to change the shortcut key) except the first one, SpeakMailThreaded, since all four of the scripts refer to that name. If you change the SpeakMailThreaded script's name, you'll have to edit all the scripts to update to the new name.

Let me know what you think of them, and any major bugs. I know it sometimes hangs if Mail hangs waiting for a password or something, but I haven't figured out a way around that yet. I might add the ability to grab speech from some high-quality web site voices, such as naturalvoices.att.com, but I haven't gotten that to be reliable enough yet.

[robg adds: These scripts worked as described for me; the automatic muting of iTunes is a very nice touch. I'm not sure I'll use these constantly (I use a visual mail indicator instead), but they do work, and show some of the capabilities of Mail and AppleScript...]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[11,725 views]  

Speak new Mail notifications via a set of scripts | 14 comments | Create New Account
Click here to return to the 'Speak new Mail notifications via a set of scripts' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Speak new Mail notifications via a set of scripts
Authored by: dogboy on Mar 08, '05 11:47:04AM

Nice. Although it does lock mail up for a while sometimes.



[ Reply to This | # ]
Speak new Mail notifications via a set of scripts
Authored by: IPA-IBA on Dec 04, '07 09:05:55AM
Seconded - this doesn't always work that smoothly! ~~ Business Information from IPA-IBA

[ Reply to This | # ]
Speak new Mail notifications via a set of scripts
Authored by: randydarden on Mar 08, '05 12:37:34PM
I haven't looked at your scripts, but I wrote a short Applescript to display the "From" and "Subject" lines via LanOSD. This provides a nice little temporary transparent window in the lower-right corner of my screen. Those of you interested in notifications without speech should take a look at LanOSD.

[ Reply to This | # ]
Speak new Mail notifications via a set of scripts
Authored by: Laurence Wilks on Mar 09, '05 03:06:00AM

Randydarden

Any chance of posting your scripts?



[ Reply to This | # ]
Speak new Mail notifications via a set of scripts
Authored by: mjmtaiwan on Mar 09, '05 03:00:53PM

Yep... I'm interested to... though I did use the original scripts in this thread and they are great! However, I often have the speakers muted and a visual que would be nice too.

Mike

---
Old Time Radio from the 30s, 40s and 50s



[ Reply to This | # ]
Speak new Mail notifications via a set of scripts
Authored by: Tomnibus on Mar 08, '05 12:57:18PM

I have had a series of scripts that has done this for about 5 years that I use with MS Entourage.

Although, it's not as in-depth as this example and it's a little more rudimentary but I use them all the same. The way mine work is there is one script per rule that I have defined. And the script is customized for that rule and applied to it. Say I get e-mail for a list, it will say, "Listname mail" (whatever I have manually typed in the script to say. Or I am on the "production Group" at my company so anytime mail comes in for that group it says, "Production Group Messages" Or "Personal Messages" for my personal e-mail box. So on and so forth.

However, I found that as e-mail was coming in every single e-mail (sometimes as much as 30-40 at a time) was being announced and it was ridiculous. So, I had a friend help me make a "property" in the script to announce only every 4.5 minutes (I get my mail every 5 minutes). So the first one announces but that's it. Here's an example:
[code]
property RunTime : 0

tell application "Microsoft Entourage"
set msgs to current messages -- doesn't work without temp variable
repeat with m in msgs
try
set s to m's source
set CurrentDate to time of (current date)
if RunTime + 120 ? (CurrentDate) then
say "Personal Messages"
end if

set RunTime to CurrentDate

end try
end repeat
end tell
[/code]



[ Reply to This | # ]
Speak new Mail notifications via a set of scripts
Authored by: zgafford on Mar 08, '05 03:15:50PM

I like the idea of it reading the names from address book but I only want to here the sender not the subject. Is there a way to easily change this?



[ Reply to This | # ]
Speak new Mail notifications via a set of scripts
Authored by: jporten on Mar 08, '05 04:06:07PM

Haven't looked at the scripts yet, but you can comment out the relevant "say" command by typing "--" at the beginning of the line in Script Editor.



[ Reply to This | # ]
Speak new Mail notifications via a set of scripts
Authored by: ephramz on Mar 08, '05 06:51:50PM
zgafford- ephramz here, the script writer. You could just put the line
			set theSubject to ""
before this line in the main script "Say Mail Threaded___ctl-z"
			-- determine if this is a reply
But this script is kind of overkill if you don't want to hear the subjects since that's what it's mainly set up to do. If you don't want the names taken from the address book, you can just use some of these earlier speaking mail script hints: here, here, and here,

[ Reply to This | # ]
Speak new Mail notifications via a set of scripts
Authored by: dwise on Oct 05, '05 08:37:04AM

You need edit the SayMailThreaded script with the Script Editor and modify it as show:


if msgReply then
set speechText to group & " reply from " & fromPerson
(*& " about " & theSubject*)
Put this part of line between Parenthesis and asterisc
else if aForward then
-- or if it's a forward
set speechText to group & "forward from " & fromPerson
(*& " about " & theSubject*)
Put this part of line between Parenthesis and asterisc
else
set speechText to "New " & group & " mail from " & fromPerson
(*& " about " & theSubject*)
Put this part of line between Parenthesis and asterisc
end if



[ Reply to This | # ]
Wow. That's a lot more complicated than mine.
Authored by: porkchop_d_clown on Mar 09, '05 09:03:06AM
Mine simply checks the address and, if the sender is in the address book, says "Mail from x". That way I don't get audibly spammed by every mailing list I'm on.
I should also point out that I get a lot of ribbing from co-workers who aren't overly fond of hearing their names mispronounced by the Mac.

---
Everyone loves a clown, but no one will lend him money!

[ Reply to This | # ]

Speak new Mail notifications via a set of scripts
Authored by: randydarden on Mar 11, '05 11:52:13AM

Looks like I used an Apple sample "rule action" script for Mail.. I simply replaced the guts with these lines:

try
	set theText to "New mail:" & return & "From: " & theSender & return & "Subject: " & theSubject
	
	-- add an extra newline if multiple messages are to be displayed
	if numberOfMessages > 1 then
		set theText to theText & return
	end if
	
	tell application "LanOSD"
		message kind "message" text theText quadrant 8 icon "email" fade delay "8"
	end tell
	
	set theText to ""
end try

And added a Mail rule to call this AppleScript when receiving new message from certain accounts.

One drawback is when you download lots of messages from an account, Mail will slow to a crawl and LanOSD's indications will fill up the screen. You might avoid this with another rule.



[ Reply to This | # ]

LanOSD script
Authored by: randydarden on Mar 11, '05 11:53:55AM

Oops, that was supposed to be in reply to those asking for my LanOSD Mail script.

Also, I forgot to mention that the script I started with is here:
"/Library/Scripts/Mail Scripts/Rule Actions/Sample Rule Action Script.scpt"



[ Reply to This | # ]
Minor warning for users of this script
Authored by: porkchop_d_clown on Mar 14, '05 12:19:39PM

I just figured out that the "contains" operation is case sensitive, and using "ignoring case" doesn't help.

This was triggered because I was getting mail from "MyAddress@someplace.com" but in my address book it was "myaddress@someplace.com".

Note that, technically, smtp addresses are supposed to be case-insensitive.

---
Everyone loves a clown, but no one will lend him money!



[ Reply to This | # ]