casouri

Q: Start dictation from terminal or appleScript

Is there anyway to start dictation from terminal or appleScript?

THe reason I ask is that I want to make a voice control program that can get input through dictation.

now I can only start a workflow with a voice command, instead of start a dictation and use it as input of the program.

Anyone has ideas? Thanks.

MacBook Pro with Retina display, OS X El Capitan (10.11.2)

Posted on Mar 30, 2016 2:54 PM

Close

Q: Start dictation from terminal or appleScript

  • All replies
  • Helpful answers

  • by VikingOSX,

    VikingOSX VikingOSX Mar 30, 2016 3:36 PM in response to casouri
    Level 7 (20,591 points)
    Mac OS X
    Mar 30, 2016 3:36 PM in response to casouri

    This might be helpful.

     

    Also, don't rule out the System Preferences : Accessibility : Dictation : Dictation Commands… where you have the ability to create a new voice command that performs the actions in a specified Automator Workflow.

     

    One of my annoyances was that some applications export a PDF and then hide the extension. I created an Automator Workflow (restore_file_extension.workflow) that by selecting the file, and simply saying “Show Extension,” the workflow would tell Finder to display the selected filename extension. You can watch the extension abruptly appear. That Automator workflow file can be anywhere in your home folder. The perform selection (below) lets you walk to the file location and select it. Instead of an Automator Workflow, it can be just a compiled (.scpt/.scptd) AppleScript. You would press fn fn prior to this paragraph to have dictation listening.

     

    Screen Shot 2016-03-30 at 6.28.28 PM.jpg

    The Automator Workflow is comprised of a sole Run AppleScript action:

    Screen Shot 2016-03-30 at 6.33.19 PM.jpg

  • by casouri,

    casouri casouri Mar 30, 2016 6:10 PM in response to VikingOSX
    Level 1 (8 points)
    Mac OS X
    Mar 30, 2016 6:10 PM in response to VikingOSX

    Thank you. I find this "listen for" command in "Speech Recognition Suite". Can I start a dictation with it and get the sentence from it?

  • by Camelot,

    Camelot Camelot Mar 30, 2016 8:46 PM in response to casouri
    Level 8 (47,233 points)
    Mac OS X
    Mar 30, 2016 8:46 PM in response to casouri

    Can I start a dictation with it and get the sentence from it?


    Yes. Use something like:

     

    tell application "SpeechRecognitionServer"

      set theResponse to listen for {"1", "2", "3", "4", "5"} with prompt "pick a number between 1 and 5"

      say "You picked " & theResponse

    end tell

     

    Note that the phrase that SpeechRecognitionServer detected is returned in theResponse.

  • by casouri,

    casouri casouri Mar 30, 2016 9:27 PM in response to Camelot
    Level 1 (8 points)
    Mac OS X
    Mar 30, 2016 9:27 PM in response to Camelot

    THanks! It's really helpful.

    However, what is that prompt used for? Is it a window, a command that I say, or a dialog computer says?

  • by Camelot,

    Camelot Camelot Mar 30, 2016 10:09 PM in response to casouri
    Level 8 (47,233 points)
    Mac OS X
    Mar 30, 2016 10:09 PM in response to casouri

    Try it

     

    The prompt is what the SpeechRecognitionServer uses to tell you it's listening, and what it's listening for.

     

    If you don't want a prompt and instead want the server to listen continuously, use the listen continuously for command instead.

  • by VikingOSX,

    VikingOSX VikingOSX Mar 31, 2016 3:16 AM in response to casouri
    Level 7 (20,591 points)
    Mac OS X
    Mar 31, 2016 3:16 AM in response to casouri

    There was an example of using listen for in that link that I provided in my previous post.

  • by casouri,

    casouri casouri Mar 31, 2016 5:24 AM in response to Camelot
    Level 1 (8 points)
    Mac OS X
    Mar 31, 2016 5:24 AM in response to Camelot

    THank you!

  • by casouri,

    casouri casouri Mar 31, 2016 5:29 AM in response to VikingOSX
    Level 1 (8 points)
    Mac OS X
    Mar 31, 2016 5:29 AM in response to VikingOSX

    I'm sorry but I can't find your previous post. Thank you though.

  • by VikingOSX,

    VikingOSX VikingOSX Mar 31, 2016 6:45 AM in response to casouri
    Level 7 (20,591 points)
    Mac OS X
    Mar 31, 2016 6:45 AM in response to casouri

    I posted two previous responses to you in this thread. The first one has the word “might” as a hyperlink to a whole article on what you want to do, and with examples.

  • by casouri,

    casouri casouri Mar 31, 2016 3:43 PM in response to VikingOSX
    Level 1 (8 points)
    Mac OS X
    Mar 31, 2016 3:43 PM in response to VikingOSX

    I didn't see your response before I click "show more comments". My bad, first time come here to ask questions.

    Thanks, that really helps, I've begin to write my program : )