Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BusFactor1Inc/4fb56c2989db1db5e6f1cb74a9fb7e00 to your computer and use it in GitHub Desktop.
Save BusFactor1Inc/4fb56c2989db1db5e6f1cb74a9fb7e00 to your computer and use it in GitHub Desktop.
An example AppleScript Voice Control Shell named "Heidi"
-- AppleScript Voice Control Shell, Heidi
--
-- BusFactor1 Inc. - 2017
set commands to {"help", "exit", "screensaver", "laugh", "tell me a joke"}
on hear(commands)
try
tell application "SpeechRecognitionServer" -- <callout id="code.osx-voice-automation.scpt.speechrecognizer"/>
activate
return listen for commands -- giving up after 7
end tell
on error
return ""
end try -- there is only do
end hear
set firstPrompt to 0
on prompt(commands, firstPrompt)
if the firstPrompt is equal to 0 then
say "I will execute your commands. Say my name, Heidi, to get my attention."
say "Use the help command to have me tell you my capabilities."
else
say "Please address me to enter a command."
end if
my hear({"Heidi"})
say "What is your command?"
return my hear(commands)
end prompt
say "Welcome to your Voice Control Shell."
repeat
set command to my prompt(commands, firstPrompt)
set firstPrompt to firstPrompt + 1
if the command is equal to "exit" then
say "Thank you for letting me serve you."
return
else if command is equal to "help" then
say "Help will be coming shortly."
else if the command is equal to "" then
say "I'm listening"
else if command is equal to "tell me a joke" then
say "The past, present and future walk into a bar. ,,It was tense."
else if the command is equal to "laugh" then
say "This is no laughing matter."
else if the command is equal to "screensaver" then
say "I don't know how to turn on the screensaver yet."
else
say "The command was unrecognized. It was " & the command
end if
end repeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment