6 Replies Latest reply: May 2, 2012 7:20 PM by greenyouse
greenyouse Level 1 Level 1 (30 points)

Hi, I was writing a few AppleScripts with speech commands (in Snow Leopard) but I ran into errors with my Speech Recognition Server application.  I know that this is a pretty old subject but were there ever any workarounds released to solve the issue?


MacBook, Mac OS X (10.6.8)
  • 1. Re: Speech Recognition Server Fix?
    Camelot Level 8 Level 8 (45,790 points)

    Kind of hard to answer your question without more details - what kind of errors are you getting?

     

    Speech Recognition is still supported in 10.7, so there's little reason why it wouldn't work, but without knowing what kind of issues you're running into, it's hard to tell you what needs to change.

  • 2. Re: Speech Recognition Server Fix?
    greenyouse Level 1 Level 1 (30 points)

    Running an AppleScript like the one below will not work correctly on my computer.  I have speech recognition turned on but it will either give me the prompt and then hang until the script times out or just hang until the script times out without asking me for the prompt at all.

    tell application "SpeechRecognitionServer"

              set theResponse to listen for {"yes", "no"} with prompt "Hello. Do you like me?"

              if theResponse is "yes" then

                        say "I like you, too."

              else

                        say "I don't care whether you like me or not."

              end if

    end tell

     

    I was looking around and it seemed that other people had similar problems (macscripter discussion, previous apple support question).  Do you have any advice?

  • 3. Re: Speech Recognition Server Fix?
    twtwtw Level 5 Level 5 (4,690 points)

    two things:

     

    first, try not to put osax-based commands inside of application tells.  'say' is a command in the standard additions osax, and is not guranteed to work when called in  any context other than the main script context.  rewrite like so:

     

    tell application "SpeechRecognitionServer"

              set theResponse to listen for {"yes", "no"} with prompt "Hello. Do you like me?"

    end tell

     

    if theResponse is "yes" then

              say "I like you, too."

    else

              say "I don't care whether you like me or not."

    end if

     

    second, and more to the point, you need to hold down the escape key (by default) to get the speech recognition server to listen.  you'll know it's listening because the microphone will go from gray to black and moving arrows will appear pointing in at the mic.

  • 4. Re: Speech Recognition Server Fix?
    greenyouse Level 1 Level 1 (30 points)

    Ok, I didn't know about moving the 'say' commands outside of the tell block, I'll do that.  The speech recognition was already set up on my computer and it works well on everything except AppleScript Editor. 

     

    I tried running your version of the script and it works on the first run, but then it gets stuck and never says the prompt or listens to anything on any of the runs after that.  Do you have any ideas for what could be causing it / how to fix it?

  • 5. Re: Speech Recognition Server Fix?
    twtwtw Level 5 Level 5 (4,690 points)

    On my machine it works on alternate runs, and I set a 'getComponentVersion failed' error in console.  Apparently the speech recognition server is hanging after processing a command.  probably needs a bug report to apple.  you can solve the problem hackishly by adding the following line at the end of the script:

     

    do shell script "killall SpeechRecognitionServer"

     

    this kills the server immediately, letting the script run next invocation.

  • 6. Re: Speech Recognition Server Fix?
    greenyouse Level 1 Level 1 (30 points)

    Thank you, that seems to get the job done.  From now on I guess I'll try to follow up groups of listen and say commands with the killall command. 

     

    Thanks again!