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