Applescript help. Please!!!

Joined
May 5, 2010
Messages
1
Reaction score
0
Points
1
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
 
Joined
May 14, 2009
Messages
2,052
Reaction score
136
Points
63
Location
Near Whitehorse, Yukon
Your Mac's 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.:Angry-Tongue:
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

##

[B]tell application "SpeechRecognitionServer" to set theResponse to [/B]listen for {"good to hear Jarviss.", "im glad your day went well.", "thats good."}[B] with prompt theChoice[/B]

[B]if theResponse is [/B]"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

[B]if theResponse is [/B]"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

[B]if theResponse is [/B]"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
   [B] tell application "SpeechRecognitionServer" to set theResponse to [/B]listen for {"i hope it went well.", "im glad you got some work done.", "thats good."}
end if

[B]if theResponse is [/B]"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

[B]if theResponse is [/B]"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

[B]if theResponse is [/B]"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
    [B]tell application "SpeechRecognitionServer" to set theResponse to [/B]listen for {"im sorry to hear that Jarviss.", "im glad you fixed it.", "thats too bad."}
end if

[B]if theResponse is [/B]"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

[B]if theResponse is [/B]"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

[B]if theResponse is [/B]"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
    [B]tell application "SpeechRecognitionServer" to set theResponse to [/B]listen for {"always loyal Jarviss.", "im flattered.", "thats nice of you Jarviss."}
end if

[B]if theResponse is [/B]"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

[B]if theResponse is [/B]"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

[B]if theResponse is [/B]"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
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top