Friday, February 26, 2010

Control your camera by voice

Now this is fun. Did you know that every Mac comes with built-in speech recognition? Since all Apple laptops and the iMac come with a built in microphone you only need to know how to use AppleScript to voice control your camera using a Zephir or an Arduino I/O board.

You find the control panel under System Preferences- Speech. At first click on Calibrate ... to set the levels and train the system.

The following AppleScript listens for an hour for one of three keywords and starts or stops video or shoots a photo on one of the new Canon EOS DSLRs while you're hands are free to do other things. See previous posts for details on the Zephir.

tell application "ZephIR" to activate --get ZephIR ready
delay 2
tell application "System Events" to set visible of process "ZephIR" to false --hide ZephIR

tell application "SpeechRecognitionServer"
set command to listen for {"shoot photo", "shoot video", "exit"} giving up after 3600 --seconds
end tell
on error
display alert "Listening session timed out. Start script again."
end try

if command is "shoot video" then
tell application "ZephIR" to fire zephir command "START-STOP VIDEO" of component "Canon RC-1"
else if command is "shoot photo" then
tell application "ZephIR" to fire zephir command "SHOOT PHOTO" of component "Canon RC-1"
else if command is "exit" then
delay 1
say "Good bye"
end if
end repeat

You can also demand a keyword (e.g. okay) before each command like okay shoot video, okay shoot photo and okay exit.

No comments:

Post a Comment