Results 1 to 2 of 2
  1. #1


    Member Since
    May 05, 2010
    Posts
    1
    Unhappy Applescript help. Please!!!
    hi ive been trying to make this script work
    but im quite new to applescript and i cant figure out whats wrong with it
    id appreciate whatever help you could give
    im running speech recognition software on mac os x 10.5.8 leopard
    thanks
    x

    script:

    set theOptions to {"i have had a very pleasant day sir.","oh you know, just been crunching some numbers.","quite bad, my cpu's been full up, all day!","well it is rather boring without you sir!"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice

    if theChoice is equal to "i have had a very pleasant day sir." then
    tell application "speech feedback"
    listen for("good to hear Jarviss.", "im glad your day went well.", "thats good.")

    if "good to hear Jarviss." then
    set theOptions to {"thank you sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion

    if "im glad you day went well." then
    set theOptions to {"thank you sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    end if

    if "thats good." then
    set theOptions to {"thank you sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    end if
    end tell

    if the theChoice is equal to"oh you know, just been crunching some numbers." then
    tell application "speech feedback"
    listen for ("i hope it went well.", "im glad you got some work done.", "thats good.")
    end tell

    if "i hope it went well." then
    set theOptions to {"and I also sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion

    if "im glad you got some work done." then
    set theOptions to {"me too sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    end if

    if "thats good." then
    set theOptions to {"yes, it is sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    end if
    else

    if theChoice is equal to"quite bad, my cpu's been full up, all day!" then
    tell application "speech feedback"
    listen for("im sorry to hear that Jarviss.", "im glad you fixed it.", "thats too bad.")
    end tell

    if "im sorry to hear that Jarviss." then
    set theOptions to {"thank you for thee condolences sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion

    if "im glad you fixed it." then
    set theOptions to {"no problem is too large for me sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    end if

    if "thats too bad." then
    set theOptions to {"i agree sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    end if

    if theChoice is equal to"well it is rather boring without you sir!" then
    tell application "speech feedback"
    listen for("always loyal Jarviss.", "im flattered.", "thats nice of you Jarviss.")
    end tell

    if "always loyal Jarviss." then
    set theOptions to {"always and forever sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion

    if "im flattered." then
    set theOptions to {"i mean it sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    end if

    if "thats nice of you Jarviss." then
    set theOptions to {"im pleased you think so sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    end if






    BTW this is for a home automation system, im setting up on my mac, similar to chad barraford's project J.A.R.V.I.S.

    oh and ive spelt it jarviss because that is easier for my mac to understand.

    EDIT:

    i now edited it to try this script

    set theOptions to {"i have had a very pleasant day sir.","oh you know, just been crunching some numbers.","quite bad, my cpu's been full up, all day!","well it is rather boring without you sir!"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice

    if theChoice is equal to "i have had a very pleasant day sir." then
    tell application "speech feedback"
    listen for("good to hear Jarviss.", "im glad your day went well.", "thats good.")

    if "good to hear Jarviss." then
    set theOptions to {"thank you sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    else if "im glad you day went well." then
    set theOptions to {"thank you sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    else if "thats good." then
    set theOptions to {"thank you sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    end if
    end tell

    if the theChoice is equal to"oh you know, just been crunching some numbers." then
    tell application "speech feedback"
    listen for ("i hope it went well.", "im glad you got some work done.", "thats good.")

    if "i hope it went well." then
    set theOptions to {"and I also sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    else if "im glad you got some work done." then
    set theOptions to {"me too sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    else if "thats good." then
    set theOptions to {"yes, it is sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    end if
    end tell

    if theChoice is equal to"quite bad, my cpu's been full up, all day!" then
    tell application "speech feedback"
    listen for("im sorry to hear that Jarviss.", "im glad you fixed it.", "thats too bad.")

    if "im sorry to hear that Jarviss." then
    set theOptions to {"thank you for thee condolences sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    else if "im glad you fixed it." then
    set theOptions to {"no problem is too large for me sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    else if "thats too bad." then
    set theOptions to {"i agree sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    end if
    end tell

    if theChoice is equal to"well it is rather boring without you sir!" then
    tell application "speech feedback"
    listen for("always loyal Jarviss.", "im flattered.", "thats nice of you Jarviss.")

    if "always loyal Jarviss." then
    set theOptions to {"always and forever sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    else if "im flattered." then
    set theOptions to {"i mean it sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    else if "thats nice of you Jarviss." then
    set theOptions to {"im pleased you think so sir, how was your day?"}
    set theChoice to some item of theOptions
    say theChoice displaying theChoice with waiting until completion
    end if
    end tell

  2. #2

    McYukon's Avatar
    Member Since
    May 14, 2009
    Location
    Near Whitehorse, Yukon
    Posts
    2,052
    Specs:
    2012 MBP i7 2.7 GHz 15" Matte - 16 GB RAM - 120 GB Intel SSD - 500 GB DataDoubler Mac OS 10.9
    Try this, I changed the text in bold.
    It compiles, see if it still does what you want it to do.
    https://secure.macscripter.net/viewtopic.php?pid=127223
    AppleScript Talking with Speech Recognition - Google Search

    Code:
    set theOptions to {"i have had a very pleasant day sir.", "oh you know, just been crunching some numbers.", "quite bad, my cpu's been full up, all day!", "well it is rather boring without you sir!"}
    set theChoice to some item of theOptions
    
    ##
    
    tell application "SpeechRecognitionServer" to set theResponse to listen for {"good to hear Jarviss.", "im glad your day went well.", "thats good."} with prompt theChoice
    
    if theResponse is "good to hear Jarviss." then
        set theOptions to {"thank you sir, how was your day?"}
        set theChoice to some item of theOptions
        say theChoice displaying theChoice with waiting until completion
    end if
    
    if theResponse is "im glad you day went well." then
        set theOptions to {"thank you sir, how was your day?"}
        set theChoice to some item of theOptions
        say theChoice displaying theChoice with waiting until completion
    end if
    
    if theResponse is "thats good." then
        set theOptions to {"thank you sir, how was your day?"}
        set theChoice to some item of theOptions
        say theChoice displaying theChoice with waiting until completion
    end if
    
    ##
    
    if the theChoice is equal to "oh you know, just been crunching some numbers." then
        tell application "SpeechRecognitionServer" to set theResponse to listen for {"i hope it went well.", "im glad you got some work done.", "thats good."}
    end if
    
    if theResponse is "i hope it went well." then
        set theOptions to {"and I also sir, how was your day?"}
        set theChoice to some item of theOptions
        say theChoice displaying theChoice with waiting until completion
    end if
    
    if theResponse is "im glad you got some work done." then
        set theOptions to {"me too sir, how was your day?"}
        set theChoice to some item of theOptions
        say theChoice displaying theChoice with waiting until completion
    end if
    
    if theResponse is "thats good." then
        set theOptions to {"yes, it is sir, how was your day?"}
        set theChoice to some item of theOptions
        say theChoice displaying theChoice with waiting until completion
    else
    
    ##
    
    if the theChoice is equal to "quite bad, my cpu's been full up, all day!" then
        tell application "SpeechRecognitionServer" to set theResponse to listen for {"im sorry to hear that Jarviss.", "im glad you fixed it.", "thats too bad."}
    end if
    
    if theResponse is "im sorry to hear that Jarviss." then
        set theOptions to {"thank you for thee condolences sir, how was your day?"}
        set theChoice to some item of theOptions
        say theChoice displaying theChoice with waiting until completion
    end if
    
    if theResponse is "im glad you fixed it." then
        set theOptions to {"no problem is too large for me sir, how was your day?"}
        set theChoice to some item of theOptions
        say theChoice displaying theChoice with waiting until completion
    end if
    
    if theResponse is "thats too bad." then
        set theOptions to {"i agree sir, how was your day?"}
        set theChoice to some item of theOptions
        say theChoice displaying theChoice with waiting until completion
    end if
    
    ##
    
    if the theChoice is equal to "well it is rather boring without you sir!" then
        tell application "SpeechRecognitionServer" to set theResponse to listen for {"always loyal Jarviss.", "im flattered.", "thats nice of you Jarviss."}
    end if
    
    if theResponse is "always loyal Jarviss." then
        set theOptions to {"always and forever sir, how was your day?"}
        set theChoice to some item of theOptions
        say theChoice displaying theChoice with waiting until completion
    end if
    
    if theResponse is "im flattered." then
        set theOptions to {"i mean it sir, how was your day?"}
        set theChoice to some item of theOptions
        say theChoice displaying theChoice with waiting until completion
    end if
    
    if theResponse is "thats nice of you Jarviss." then
        set theOptions to {"im pleased you think so sir, how was your day?"}
        set theChoice to some item of theOptions
        say theChoice displaying theChoice with waiting until completion
    end if
    end if
    Use the reputation system if a post helps you!
    Mac Forums IRC Channel - Help build it by hanging out with us
    The next sentence is true. The previous sentence is false.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Applescript
    By EdMarx in forum OS X - Apps and Games
    Replies: 0
    Last Post: 02-10-2012, 04:06 AM
  2. Applescript
    By SgtDave in forum OS X - Development and Darwin
    Replies: 6
    Last Post: 01-19-2011, 03:50 PM
  3. Applescript help please?
    By thtguyjosh in forum OS X - Apps and Games
    Replies: 8
    Last Post: 08-22-2010, 07:22 PM
  4. Applescript
    By nixonbw in forum OS X - Operating System
    Replies: 0
    Last Post: 07-17-2008, 07:00 PM
  5. AppleScript
    By TehHero in forum OS X - Apps and Games
    Replies: 0
    Last Post: 01-26-2008, 09:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •