View Full Version : Applescript: creating a variable Speakable Item
Dragolux
06-06-2010, 09:08 PM
Hey everyone,
I just recently started playing around with Mac's Speakable Items/Voice Control powers, and I have to admit - they are really cool!
However, I do have a question. I was wondering - is it possible to, instead of having to say a set phrase (like "Play iTunes"), could you make it so that you can have the phrase accept a "variable" like "Play playlist 'awesome songs'"? The script would somehow read the "awesome songs" text into a variable and then you could use that variable to select the playlist from iTunes.
Is this possible?
Thanks!
Dragolux
renaultssoftware
06-07-2010, 03:40 PM
AFAIK it's not something that's obvious. In fact, most commands say 'do this with this item' not 'do this with "My Item"' in the commands.
macosnoob
06-07-2010, 04:59 PM
This old hint from the mothersite may get you started: A script to use voice recognition with iTunes, http://www.macosxhints.com/article.php?story=2003022401411159. Doug's Scripts, http://dougscripts.com, is also a good place to look for what you're seeking.
Dragolux
06-07-2010, 06:47 PM
Thanks for the replies!
I looked at both of those links, and though they seem to be just what I'm looking for, they aren't working. Here's a sample script that I'm using:
say "Please say yes or no"
tell application "SpeechRecognitionServer"
set t to listen for {"yes", "no"}
end tell
if t is "yes" then
say "will do now"
else
if t is "no" then
say "see you soon"
end if
end if
It compiles and (seemingly) executes, and even says "Please say yes or no", but when I hold down the escape key and say "yes", nothing happens.
Could this be a problem with the SpeechRecognitionServer section?
renaultssoftware
06-07-2010, 07:51 PM
Here's my thought on this: Open System Preferences » Speech and enable both options in "Upon Recognition" then see what happens. If it doesn't hear you then try again until it does. I tried your script after editing the recursive if block (else if fulfilled that purpose nicely) and found I had to try twice to make it hear me. It's fine otherwise.
Dragolux
06-07-2010, 08:18 PM
Hmm...It's still not working for you.
What exactly are you doing to make it work? This is what I do:
1. Open up the Speech pane in System Prefs.
2. Turn SR on.
3. Push the F1 button down (I use it instead of Escape).
4. Say "Try", what I named the script.
5. Release the F1 button.
6. After it says "Please say yes or no", I push the F1 button down, say "Yes", and then let go of the button.
And nothing happens. Ever. :( Am I doing something wrong?
renaultssoftware
06-08-2010, 07:05 AM
You repeat step 6 until it works, I hope. Give up after 10 times if you want
Dragolux
06-11-2010, 12:30 PM
Well it isn't working for me for some reason. :( Oh well, it's not really essential. Thanks for the help!
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.