Automation Apple脚本,用于聆听是或否的答案
事实上,我已经有了这个脚本(作为一个完全的初学者,我感到很惊讶),但我只是想确保这个脚本没有多余的代码,我不需要。或者如果有更好的方法,请评论!我最终尝试创建一系列语音命令Automation Apple脚本,用于聆听是或否的答案,automation,applescript,voice-recognition,Automation,Applescript,Voice Recognition,事实上,我已经有了这个脚本(作为一个完全的初学者,我感到很惊讶),但我只是想确保这个脚本没有多余的代码,我不需要。或者如果有更好的方法,请评论!我最终尝试创建一系列语音命令 tell application "SpeechRecognitionServer" set l1 to {"yes", "sure", "yes please", "open mail"} set l2 to {"no", "no thanks", "not now"} set no_answer to {"no", "n
tell application "SpeechRecognitionServer"
set l1 to {"yes", "sure", "yes please", "open mail"}
set l2 to {"no", "no thanks", "not now"}
set no_answer to {"no", "no thanks", "not now"}
set answer to listen for l1 & l2 with prompt "Would you like me to open your email"
l1 contains answer
l2 contains no_answer
end tell
if l1 contains answer then
say "yes answer"
else if l2 contains no_answer then
say "no answer"
end if
end
提前谢谢 您应该只在tell块中包含属于您正在“讲述”的应用程序的命令。在块外建立列表
set l1 to {"yes", "sure", "yes please", "open mail"}
set l2 to {"no", "no thanks", "not now"}
这没有任何作用
l1 contains answer
l2 contains no_answer
l2将始终不包含任何答案,因为它们是两个静态列表
else if l2 contains no_answer
请尝试以下方法:
set l1 to {"yes", "sure", "yes please", "open mail"}
set l2 to {"no", "no thanks", "not now"}
activate application "SpeechRecognitionServer"
try
tell application "SpeechRecognitionServer" to set answer to listen for l1 & l2 with prompt "Would you like me to open your email" giving up after 20
on error number -128
say "User did not respond"
error number -128
end try
if l1 contains answer then
say "yes answer"
else if l2 contains answer then
say "no answer"
end if