Speech Recognition Server shutting off after first sentence

Hi everyone, I started on this new script to show my wife what her new computer could do. I had it working fine with it starting the greeting at resultingstring2, but wanted to add the script to listen for her to say “Good morning Mac”. It listens for her, then says its good morning with resultingstring2, but then the speech orb disappears after it finishes resultingstring2, and it’s not listening anymore. I have tried scripting it a dozen ways to no avail. Thank you in advance, adown

set Morning_Greeting to "Good Morning Marni"
set Morning_Greeting2 to "Good [[emph ++]]Morning Marni,"
set TheTime to (time string of (current date))
set myTime to words of TheTime
set Current_time to (item 1 of myTime) & ":" & (item 2 of myTime) & ", "
set question to " Where would you like to start"
set resultingString to Morning_Greeting & " The current time is " & Current_time & return & question
set resultingstring2 to Morning_Greeting2 & " ,The [[emph +]]current time is " & Current_time & return & question
set mainLogin to "********" as text
set mainPword to "********" as text
tell application "SpeechRecognitionServer" to set firstResponse to listen for {"good morning mac"}
if the firstResponse is "good morning mac" then
	say resultingstring2
else
	
end if

tell application "SpeechRecognitionServer" to set secondResponse to listen for {"mail", "facebook", "msn", "the firm", "ebay"}
if secondResponse is "msn" then
	tell application "Safari"
		activate
		open location "http://www.msn.com"
	end tell
else if secondResponse is "facebook" then
	tell application "Safari"
		activate
		open location "http://www.facebook.com/"
	end tell
else if secondResponse is "mail" then
	tell application "Mail"
		activate
		if (count of message viewers) is 0 then
			make new message viewer at front
			set selected mailboxes of message viewer 1 to {inbox}
		end if
	end tell
else if secondResponse is "ebay" then
	tell application "Safari"
		activate
		open location "http://www.ebay.com"
	end tell
else if secondResponse is "the firm" then
	tell application "Safari"
		activate
		open location "http://www.firmdirect.com/firm/ecs/main/login.html"
	end tell
	delay 0.5
	tell application "System Events"
		tell application process "Safari"
			keystroke (ASCII character 9)
			keystroke mainLogin
			keystroke (ASCII character 9)
			keystroke mainPword
			keystroke (ASCII character 13)
		end tell
	end tell
	
end if/applescript]

Two options I see:

  1. You may want to try adding IDLE commands at the beginning and save the applescript as ‘Keep open’ in the save dialog box…


on idle
   tell application "SpeechRecognitionServer" to set secondResponse to listen for {"mail", "facebook", "msn", "the firm", "ebay"}
if blah blah 
....
....
....
....
end if 

end idle

  1. You can break each command into its own action, add it to the Speakable Items folder to make it speakable.

To open something using a spoken command, just add it to the Speakable Items folder.

The filename of the item is the command you say to open it. Be sure to follow the guidelines for naming speech commands.

After you add an item to the folder, wait about 20 seconds before using it.

http://docs.info.apple.com/article.html?artnum=61493