我正在开发一个包含聊天机器人的项目,我正在使用“ Sapi.h”。 该代码会在屏幕上显示一条合适的消息,然后让机器人说出来,当然还要输入类似的信息,例如,机器人在激活时将执行以下操作: “您好,我该如何帮助您” --->最近的语音留言->用户输入。 但是会发生什么,当前两个语句运行时,它们不是同时运行的,我希望用户在机器人正在拼写他应该说的短语的同时键入他的问题。 BotActivationFunction:
void ChatBotActivate(Pharmacy P)
{
srand(time(0));
//This Is The Opening message
string Greeting_Message = Sentences[0][rand() % 2];
cout << Greeting_Message << endl;
//the object bot_voice which will basically call the function speakphrase who's responsible on spelling the phrase
Bot_Voice->SpeakPhrase(Conv(Greeting_Message));
//while the customer didn't finish with all his questions
while (true)
{
string CustomerQuestion;
//the GetLine is not showing inputed words until the bot has finished speaking
getline(cin, CustomerQuestion);
std::vector<string> Tmp = SliceString(CustomerQuestion);
auto Thank_Search = std::find_if(Tmp.begin(), Tmp.end(), [](string S) {return InSensitiveComparison(S, "Thank"); });
auto Thanks_Search = std::find_if(Tmp.begin(), Tmp.end(), [](string S) {return InSensitiveComparison(S, "Thanks"); });
if (Thank_Search != Tmp.end() || Thanks_Search != Tmp.end())
{
cout << Sentences[2][0] << endl;
Bot_Voice->SpeakPhrase(Conv(Sentences[2][0]));
break;
}
//won't include answer customer because it's pretty long
AnswerCustomer(CustomerQuestion, P);
}
}
尝试使用std :: thread进行操作,但即使我尝试使用std :: thread(Constructor)从一个lambda调用成员函数,它似乎也不适用于对象成员函数。
无论如何,我可以使用std :: getline或std :: thread来解决此问题