I have been working on a scripte for my voice recognition. It works fine. But once you atart, you can stop it. It will just sit there and throw a “timed out” error. Anyone know the cause of this? It is a fun script to use, esecially with home automation, ut t is locking up the script editor.
tell application "SpeechRecognitionServer"
set heardPhrase to listen for {"lights on", "turn off lights", "call friend", "quit ichat", "play music", "turn music off"}
end tell
if heardPhrase is "lights on" then
tell application "Indigo"
activate
delay 5
execute group ("all on")
end tell
else if heardPhrase is "turn off lights" then
tell application "Indigo"
activate
delay 5
execute group ("all off")
end tell
else if heardPhrase is "call friend" then
tell application "iChat"
activate
delay 5
set theStatus to get capabilities of account "josh metts"
if theStatus contains video chat then
send video invitation to account "Josh Metts"
else
quit "ichat"
end if
end tell
else if heardPhrase is "quit ichat" then
tell application "iChat"
close window "video chat with josh metts"
quit "ichat"
end tell
else if heardPhrase is "play music" then
tell application "iTunes"
activate
delay 5
play playlist "top 25 most played"
end tell
else if heardPhrase is "turn music off" then
tell application "iTunes"
quit
end tell
end if
This is weird. I was running that script. It worked great, but now it goes right through the tell/end tell routine without any input. Try it on your and see if does the same thing.
tell application "SpeechRecognitionServer"
activate
try
set heardPhrase to listen for {"lights on", "turn off lights", "call friend", "quit ichat", "play music", "turn music off"} giving up after 2 * days
on error -- time out
return
end try
end tell
You might try setting the speech preference for input volume. Try placing a beep in the error handler to see if an error is occuring. I’m using Jaguar, so maybe they made a change. Try not using 1*days, but an integer instead. That’s all I can think of right now.
editted: I splke too fast. The same is happening here. Checking it out.
If it starts acting up again, you can try testing this out.
set t to 1 * days
tell application “SpeechRecognitionServer”
repeat
try
listen continuously for {“hello”, “bye”} with identifier “Set 1” giving up after t
set user_reply to result
if user_reply is “hello” then
say “hello”
else
say “bye”
exit repeat
end if
on error
beep 2
end try
do shell script “sleep 1”
end repeat
stop listening for identifier “Set 1”
end tell
I think it had something to do with the SpeechRecognitionServer process and its accompanying Speech Feedback taking a long time to quit. What I think is that is the script is rerun while they’re still present, then it starts timing out. It’s like going back to the default timeout.