-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathrobot.cpp
More file actions
52 lines (47 loc) · 1.59 KB
/
Copy pathrobot.cpp
File metadata and controls
52 lines (47 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "robot.h"
#include "Utils/config.h"
#include <QCoreApplication>
Robot::Robot(QObject* parent) : QObject(parent)
{
player = new Player(this);
Config::instance()->loadConfig();
wakeup = new Wakeup(player, this);
conversation = new Conversation(player, this);
#ifdef SERVER
server = new Server(conversation, this);
#endif
#ifdef MQTT
mqtt = new MQTTHandler(this);
connect(wakeup, &Wakeup::wakeup, mqtt, &MQTTHandler::onWakeup);
connect(wakeup, &Wakeup::detected, mqtt, &MQTTHandler::onDetect);
connect(conversation, &Conversation::asrRecognize, mqtt, &MQTTHandler::onASR);
connect(conversation, &Conversation::sayText, mqtt, &MQTTHandler::onSay);
#endif
connect(wakeup, &Wakeup::dataArrive, this, [=](QByteArray data){
conversation->receiveData(data);
});
connect(wakeup, &Wakeup::detected, this, [=](bool stop){
conversation->dialog(stop);
});
connect(wakeup, &Wakeup::detectedIntent, this, [=](const QString& text, const ParsedIntent& intent){
conversation->handlePlugin(text, intent, 0);
});
connect(wakeup, &Wakeup::finishResponse, conversation, &Conversation::onResponse);
connect(conversation, &Conversation::finish, this, [=](){
wakeup->resume();
});
connect(conversation, &Conversation::requestResponse, wakeup, &Wakeup::doResponse);
connect(conversation, &Conversation::exitSig, this, [=](){
stop();
QCoreApplication::exit();
});
}
Robot::~Robot(){
}
void Robot::start(){
wakeup->startWakeup();
}
void Robot::stop(){
wakeup->stopWakeup();
conversation->stop();
}