本文整理汇总了C++中ISpVoice::WaitUntilDone方法的典型用法代码示例。如果您正苦于以下问题:C++ ISpVoice::WaitUntilDone方法的具体用法?C++ ISpVoice::WaitUntilDone怎么用?C++ ISpVoice::WaitUntilDone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISpVoice
的用法示例。
在下文中一共展示了ISpVoice::WaitUntilDone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
Arguments arguments(argc, argv);
//Initialize Pocketsphinx
mic_data_t mic;
continuous_init(arguments, mic);
//Initialize Voice
ISpVoice * pVoice = NULL;
if (FAILED(::CoInitialize(NULL)))
return FALSE;
HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
if (SUCCEEDED(hr))
std::cout << "Speech Initialized" << std::endl;
//Initialize Rebecca
AimlFacade aiml;
GraphBuilder &builder = aiml.getGraphBuilder();
myCallBacks callback;
builder.setCallBacks(&callback);
rebecca_init(arguments, builder);
//Main code
try
{
/*
* Send a initial conversation of "connect" to
* annotated alice and get the response.
*/
StringPimpl response = builder.getResponse("connect");
/*
* Get the botName which should be Rebecca since that is
* the name give in the configuration file properties.xml
* which we parsed above.
*/
string botName = builder.getBotPredicate("name").c_str();
//Send the initial opening line of the bot
cout << botName << " says: " << response.c_str() << endl;
hr = pVoice->Speak(s2ws(response.c_str()).c_str(), 0, NULL);
pVoice->WaitUntilDone(15000);
/*
* The main loop to get the input
* from the user until the user types '/exit'
*/
while (true)
{
//getUtterance(mic);
//string input = string(mic.hyp);
string input;
getline(cin, input);
if (input == "/exit" || input == "GOOD NIGHT")
{
/*
* The user wants to exit so break
* out of the while(true) loop
*/
continuous_exit(mic);
pVoice->Release();
pVoice = NULL;
::CoUninitialize();
break;
}
else //The user gave an input to the bot
{
//Here we get some internal Rebecca information.
cout << endl
<< "Internal information:" << endl
<< "=====================" << endl
<< input << " : "
<< builder.getThat().c_str() << " : "
<< builder.getTopic().c_str() << endl;
/*
* Ahhh finally. We give the user input to Rebecca Aiml's loaded
* AIML and get the response back.
*/
StringPimpl response = builder.getResponse(input.c_str());
cout << "=====================" << endl << endl;
//Print out what Rebecca says.
cout << botName << " says: " << response.c_str() << endl;
hr = pVoice->Speak(s2ws(response.c_str()).c_str(), 0, NULL);
pVoice->WaitUntilDone(15000);
}
}
}
catch (Exception &e)
{
cout << "[An unknown exception occured, Terminating program]" << endl;
//.........这里部分代码省略.........