gpt4 book ai didi

applescript - 您如何将语音识别集成到苹果脚本中并理解关键词和多个单词

转载 作者:行者123 更新时间:2023-12-02 02:02:56 24 4
gpt4 key购买 nike

这是我用于虚拟助手的简单代码示例:

tell application "SpeechRecognitionServer"
set theResponse to listen for {"good", "bad"} with prompt "How are you?"
if theResponse is "good" then
say "Wonderful sir… Is there anything you want me to do for you?"
else
say "Cheer up chap! Is there anything you want me to do for you?"
end if
end tell

任何人都可以进一步开发它,使其能够理解超过 2 个单词并理解某些关键字吗?

最佳答案

我假设您可以使用两个列表,一个代表“好”,另一个代表“坏”:

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

抱歉,我不得不更正您的文字错误 (:

关于applescript - 您如何将语音识别集成到苹果脚本中并理解关键词和多个单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16389813/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com