【发布时间】:2011-10-29 21:39:57
【问题描述】:
我正在尝试创建一个使用 com.apple.speech.recognitionserver 循环用户语音输入的简单程序。到目前为止,我的代码如下:
set user_response to "start"
repeat while user_response is not equal to "Exit"
tell application id "com.apple.speech.recognitionserver"
set user_response to listen for {"Time", "Weather", "Exit"} with prompt
"Good Morning"
end tell
if user_response = "Time" then
set curr_time to time string of (the current date)
set curr_day to weekday of (the current date)
say "It is"
say curr_time
say "on"
say curr_day
say "day"
else if user_response = "Weather" then
say "It is hot outside. What do you expect?"
end if
end repeat
say "Have a good day"
如果在我的系统上运行上述程序,它会说早上好,然后会弹出语音输入系统并等待时间、天气或退出。他们都按照他们所说的去做,但是如果我说时间和天气,而不是循环并再次询问直到我说退出,语音服务器超时并且不再弹出。有没有办法让该应用程序保持打开直到程序结束,或者 applescript 不能循环用户语音输入?
【问题讨论】:
标签: macos applescript speech-recognition