我假设您可以使用两个列表,一个代表“好”,另一个代表“坏”:
set good_list to {"Good", "Fine", "I'm fine", "OK", "Okay"} --List of words, meaning "Good"
set bad_list to {"Bad", "Irritated", "Fustrated", "Depressed"} --List of words, meaning "Bad"
set complete_list to good_list & bad_list
tell application "SpeechRecognitionServer"
set theResponse to listen for complete_list with prompt "How are you?"
if (good_list contains theResponse) then
say "Wonderful sir… Is there anything you want me to do?"
else if (bad_list contains theResponse) then
say "Clear up, chap! Is there anything you want me to do?"
end if
end tell
请记住,列表中包含的单词或组词越多,您的脚本就越能理解!
如果你愿意,你可以让它看起来更智能,通过使用(用户的)口头回答,在计算机会说的句子中。它看起来像这样:
set good_list to {"Good", "Fine", "I'm fine", "OK", "Okay"} --List of words, meaning "Good"
set bad_list to {"Bad", "Irritated", "Fustrated", "Depressed"} --List of words, meaning "Bad"
set complete_list to good_list & bad_list
tell application "SpeechRecognitionServer"
set theResponse to listen for complete_list with prompt "How are you?"
if (good_list contains theResponse) then
if theResponse = "I'm fine" then
set theResponse to "Fine" --Otherwise you would get a very weird sentence
end if
say theResponse & " is good sir! Is there anything you want me to do?"
else if (bad_list contains theResponse) then
if theResponse = "Bad" then
set theResponse to "feeling bad" --Otherwise you would get a very weird sentence
end if
say "Oh, are you " & theResponse & "? Well, clear up chap! Is there anything you want me to do?"
end if
end tell
抱歉,我只需要更正您的文字错误(: