I'm so tickled I can't stand it. All right, so Speech Recognition stuff on a Mac is pretty darn cool by itself, but now I've got a nice Apple Script that opens up Safari with various tabs of my favorite sites, and it does this when I tell my Macbook "Get on it." Here's how I did it:
- Under System Preferences > Speech > Speech Recognition, make sure "Speakable Items" is set to "On." By default, to issue a voice command, you'll have to hold down the Esc key while you talk. I changed mine to the back tick because I use Esc in other applications to do other things; it's whatever works for you. If you want to change this, change the "Listening Key".
- Open Applications > AppleScript > Script Editor and enter the following code:
AppleScript
property links : {"http://mail.google.com/mail/", "http://www.3till7.net/wp-admin/", "http://dubious.nu/forum/index.php?action=unread", "http://icanhascheezburger.com/"}tell application "Safari"
activate
set currWindow to front window
repeat with link in links
make new tab at the end of tabs in currWindow with properties {URL:link}
end repeat
end tellThanks to Takashi Yoshida for the basis of this script. Feel free to change the links shown to whatever you want Safari to open up with. I imagine this script could also be customized for Firefox, Opera, or whatever other browser you use, but that might take some fiddling around.
- Hit the Compile button in Script Editor and make sure the code gets syntax highlighted nicely, with no warnings displayed. Go ahead and save this script wherever you would like, but give it a name like "Get on it" or something like that. Not "get_on_it", but using spaces and everything.
- Copy your snazzy new script to Library > Speech > Speakable Items. If you're copying the script with Finder, that is your local Library, so the one inside your home folder.
- Hold down Esc (or whatever you set your Listening Key to be) and say, clearly, "Get on it". If all goes well, Safari should pop open with your links opened in separate tabs, with a blank tab showing. If you already have Safari open, this will just open up those links in new tabs, leaving your current tabs alone.
Pronunciation Issues
Being a southern girl by the grace of God and all that jazz, I have a bit of an accent. For me, my Apple Script works better if I name it "Getawnit", which looks more akin to how I sound so that the voice recognizer does a better job of understanding me. You want how the Mac says it to match how you're saying it. One way to test this is to have the Mac say the written version of what you want to say as your command:
- Under System Preferences > Speech > Text to Speech, check "Speak selected text when the key is pressed". Then choose "Set Key..." to choose which key combination you want to hit to make the Mac read selected text. Just hit the desired combination while the little window is open. I have Option+S set for mine.
- Open Applications > TextEdit. Type in how you think you sound when you're saying the desired command. For example, I made a script that will activate when I say "I'm bored," but for me, my words run together and I speak quickly, so "Mbord" is the name I chose for my script.
- Select the text you just typed and hit the key combination you entered in System Preferences (like Option+S). Does the Mac's voice match how you plan to speak the command? If so, then you have a good file name for your script.
Technical note: you'll need a microphone for this to work, obviously. I'm using a Macbook with a built-in microphone and I'm running OS X Leopard.
5 Comments
Congrats. Now you need to hope that Apple doesn’t decide to interfere with, or totally remove the capability. It wouldn’t be the first time they halted user abilities for their own gain.
BTW,
Speech Recognition HOWTO by Stephen Cook, began 2000-09-13.
Hey is there a way I can make the text-to-speech feature play different chimes and gongs when it comes into contact with an asian unicode symbol? Right now it just remains silent – much honor – and gives no indication that something was missed. My uncle, who was in ‘nam, wants me to make some books on tape for him.
Oh man, Asian unicode symbols? That’s out of my league. I would suggest Googling for something about that, because I have no idea. Sorry!
This is great, but why on earth are you using Safari? Join the rest of the world, use Firefox.
Hi! I was surfing and found your blog post… nice! I love your blog. :) Cheers! Sandra. R.