New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Ľ Advice and insight from world-class Apple enthusiasts Ľ Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Applescript help. Please!!!


Post Reply New Thread Subscribe

 
Thread Tools
Raiden2205

 
Member Since: May 05, 2010
Posts: 1
Raiden2205 is on a distinguished road

Raiden2205 is offline
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
QUOTE Thanks
McYukon

 
McYukon's Avatar
 
Member Since: May 14, 2009
Location: Near Whitehorse, Yukon
Posts: 2,053
McYukon is a splendid one to beholdMcYukon is a splendid one to beholdMcYukon is a splendid one to beholdMcYukon is a splendid one to beholdMcYukon is a splendid one to beholdMcYukon is a splendid one to beholdMcYukon is a splendid one to beholdMcYukon is a splendid one to behold
Mac Specs: 2012 MBP i7 2.7 GHz 15" Matte - 16 GB RAM - 120 GB Intel SSD - 500 GB DataDoubler Mac OS 10.9

McYukon is offline
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.
QUOTE Thanks

Post Reply New Thread Subscribe


« Using a proxy for NSURLConnection | Interacting through one program with other programs »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
newbie question on XCode 3.2: how to populate pop up buttons/link to applescript nickharambee OS X - Operating System 0 10-21-2009 07:10 AM
Terminal vs. Applescript tgaleza OS X - Operating System 2 09-25-2009 10:08 AM
Logic Express and Applescript via GUI Scripting albertaurus Music, Audio, and Podcasting 0 04-09-2009 01:13 PM
Run applescript on start-up slugzzz Running Windows (or anything else) on your Mac 3 09-11-2007 01:51 AM
[ANN] New comprehensive AppleScript book hanaan OS X - Development and Darwin 0 11-06-2004 07:28 PM

All times are GMT -4. The time now is 03:31 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?