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

Poor-man's AppleScript vocalizer System
A bad cold has temporarily robbed me of my voice, so I decided to pay homage to Stephen Hawking and whip up a poor-man's vocalizer. More fun than function here, but it did let me order my latte at Starbucks without pain, and with a great many laughs all around.

Run this from the AppleScript Editor, save it to the Scripts Menu, or save it as an Application; whatever method works best for you.
property currentVoice : "Vicki"
set systemVoices to {"Agnes", "Albert", "Alex", "BadNews", "Bahh", "Bells", "Boing", "Bruce", 
 "Bubbles", "Cellos", "Deranged", "Fred", "GoodNews", "Hysterical", "Junior", "Kathy", 
 "Organ", "Princess", "Ralph", "Trinoids", "Vicki", "Victoria", "Whisper", "Zarvox"}

repeat
 activate me
 set theResult to display dialog "Say What?" default answer 
  "" buttons {"Quit", "Speak", "Change Voice"} 
  default button "Speak" cancel button "Quit"
 if button returned of theResult is "Quit" then
  exit repeat
 else if button returned of theResult is "Change Voice" then
  set currentVoice to item 1 of 
   (choose from list systemVoices with prompt "Choose new voice.")
 end if
 if text returned of theResult is not "" then
  say text returned of theResult using currentVoice volume 1
 end if
end repeat

[crarko adds: I tested this, and it works as described. I thinks it's a simple and clever usage of a well-known Mac feature.]
    •    
  • Currently 3.00 / 5
  You rated: 4 / 5 (6 votes cast)
 
[4,078 views]  

Poor-man's AppleScript vocalizer | 7 comments | Create New Account
Click here to return to the 'Poor-man's AppleScript vocalizer' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Poor-man's AppleScript vocalizer
Authored by: regulus on Jun 11, '11 09:49:05PM

That's a fun script. I would make one small addition to it though. It would be useful to know what the current voice is... then you would know if you should change it. As such I would add the following to the end of the "display dialog" statement. It will give the window a title which shows the current voice.

with title "Speak using " & currentVoice

---
Hank
http://www.hamsoftengineering.com



[ Reply to This | # ]
Poor-man's AppleScript vocalizer
Authored by: pmbuko on Jun 13, '11 08:03:29AM
You could also just open up the Terminal and type
say "I would like a double venti mocha frappa cheeno with soy whip, please."
If you're using a default voice other than Alex, you're crazy. :)

[ Reply to This | # ]
Poor-man's AppleScript vocalizer
Authored by: aaronrp on Jun 13, '11 08:13:26AM

Cool, although I would have just used "say" in Terminal.



[ Reply to This | # ]
Poor-man's AppleScript vocalizer
Authored by: michelle_eris on Jun 13, '11 08:21:10AM

There is an error if you click Cancel in the Change your Voice dialog. Here's the fix for it:

else if button returned of theResult is "Change Voice" then
set voiceReturned to (choose from list systemVoices with prompt "Choose new voice.")
if voiceReturned is not false then
set currentVoice to item 1 of voiceReturned
end if
end if

There's another error if the current voice is not found. One example of this is "badnews". This will handle that problem:


if text returned of theResult is not "" then
try
say text returned of theResult using currentVoice volume 1
on error number theNumber
if theNumber is -244 then
display dialog "The voice named " & currentVoice & " wasn't found"
end if
end try
end if



[ Reply to This | # ]
Poor-man's AppleScript vocalizer
Authored by: NovaScotian on Jun 13, '11 08:26:08AM

A nice addition to any AppleScript that requires a returned answer is to put a return in the default answer (just type the key). That will make the answer box 2 lines high and an answer longer than the text box will return to a second line.

display dialog "Type something longer than the box" default answer "
"
-- note the return between the quotes following default answer. That way, your to be voiced text can be quite long without its scrolling off to the left.



[ Reply to This | # ]
Re: Poor-man's AppleScript vocalizer
Authored by: Uncle Asad on Jun 13, '11 02:08:31PM

Aside from the voice-changing function of this script, isn't it easier simply to select the desired text and then invoke the "Start Speaking Text" Speech Service?



[ Reply to This | # ]
Re: Poor-man's AppleScript vocalizer
Authored by: tedw on Jun 13, '11 05:01:13PM

Maybe, if you want to play in TextEdit - I haven't actually tried it.



[ Reply to This | # ]