O'Reilly logo

AppleScript: The Missing Manual by Adam Goldstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Speaking and Listening

Just like HAL from 2001: A Space Odyssey, your Mac can talk to you. Granted, it sounds more like a Norwegian struggling to learn English than Douglas Rain, but it's still unmistakably cool.

You don't need AppleScript to make your Mac speak, though. If you just type some words in TextEdit, choose Edit Select All, and then choose Edit Speech Start Speaking, you'll get a sample of what it's like to have your Mac talk to you. This can come in handy, for example, if you've written a long paper, since it's often easier to hear typos than to find them with your eyes.

Note

If you don't like the voice you hear, go to System Preferences Speech Default Voice and select a different one. (The easiest voices to understand are Bruce, Vicki, and Victoria.) You can even set how fast they speak with the Rate slider.

Having AppleScript speak, though, is much more powerful than using TextEdit's dinky speech features. You can make an AppleScript assemble the sentences you want it to speak on-the-fly, for example, or even have AppleScript listen to your spoken commands. But best of all, you can have AppleScript speak into a file, so you can take its prerecorded speech with you on a CD or iPod.

Speaking from a Script

To make AppleScript speak to you, use the say command. Here's a simple example:

say "Hello there"

When you run that script, you'll hear "Heh-lo thay-er"—the Mac's valiant attempt at speaking English. Feel free to type whatever you want after the say command, though—you're ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required