Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kylos

macrumors 6502a
Original poster
Nov 8, 2002
948
4
MI
I wrote this sweet script that will play a playlist when you speak the phrase "select playlist" slight pause then "playlist name." Except it keeps going sour on me. When I run it from script editor (only saying the playlist name) it works fine. When I run it as a speakable script, it will work for a bit and then simply not do a thing. I test it in script editor and it works great. Basically, how this works is that the script is named "select playlist" and placed in ~/library/speech/speakable items/application speakable items/iTunes. So saying the name of the script runs the script which then listens for the playlist name. A slight pause is necessary to allow the script to run. It's cool when it works, but I can't keep it working. Any ideas? I've attached the script so you can enjoy it's coolness if you can find the problem. I haven't commented or checked for good form but it looks pretty readable to me.


Code:
set playlistlist to {}
set result to "null"
set pointer to 1
tell application "iTunes"
	repeat while playlist pointer in source "Library" exists
		copy (name of playlist pointer in source "Library") to end of playlistlist
		set pointer to pointer + 1
	end repeat
end tell
tell application "SpeechRecognitionServer"
	set result to listen for playlistlist giving up after 5 displaying playlistlist
end tell
tell application "iTunes"
	set result1 to result 
--the following line corrupts the data in variable result,
--don't know why. But declaring result1 fixes the problem
	set view of browser window 1 to playlist result
	play (playlist result1)
end tell
 
Ok, i cant help ya with the coding as im completely inept when it comes to applescript, but i just wanted to say, thats an excellent idea for a script. Nice one.
 
Thanks. Hey, anybody feel free to grab that code. To make it all work, just turn on speech recognition, switch to iTunes, and say "Make this application speakable." Then open script editor and copy the code into a new document.
Save as ~/library/speech/speakable items/Application speakable items/iTunes/select playlist. (~=home folder) If you want to be able to use this script from any application put it in speakable items directly not speakable items/application speakable items/iTunes. To use, say "select playlist" short pause "playlist name."

Right now, I've got it working again; however, I can't guarantee that it will work all the time. It seems to go in streaks. Hence the request for help.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.