Created
July 25, 2015 07:00
-
-
Save junjihashimoto/f96f5e07ef2de3767db3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <qi/applicationsession.hpp> | |
#include <qi/anyvalue.hpp> | |
using namespace qi; | |
using namespace std; | |
void call(AnyValue value){ | |
cout << "touched" << endl; | |
} | |
void call2(AnyValue value){ | |
cout << "speechreco" << endl; | |
vector<AnyValue> v = value.toList<AnyValue>(); | |
for(int i=0;i<v.size();i+=2){ | |
cout << v[i].toString() << endl; | |
cout << v[i+1].toFloat() <<endl; | |
} | |
} | |
int main(int argc, char** argv) | |
{ | |
qi::ApplicationSession app(argc, argv); | |
app.start(); | |
qi::SessionPtr session = app.session(); | |
qi::AnyObject tts = session->service("ALTextToSpeech"); | |
tts.call<void>("say", "Hello world!"); | |
qi::AnyObject rec = session->service("ALSpeechRecognition"); | |
vector<string> v; | |
v.push_back("yes"); | |
v.push_back("no"); | |
rec.call<void>("setVocabulary",v,true); | |
rec.call<void>("subscribe", "test-asr"); | |
qi::AnyObject almemory = session->service("ALMemory"); | |
AnyObject subscriber = almemory.call<AnyObject>("subscriber", "FrontTactilTouched"); | |
subscriber.connect("signal",boost::function<void(AnyValue)>(&call)); | |
// qi::AnyObject almemory = session->service("ALMemory"); | |
AnyObject subscriber2 = almemory.call<AnyObject>("subscriber", "WordRecognized"); | |
subscriber2.connect("signal",boost::function<void(AnyValue)>(&call2)); | |
// } // do not block almemory and subscriber, do not release these objects before app.run() | |
app.run(); | |
rec.call<void>("unsubscribe", "test-asr"); | |
return 0 ; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment