| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #include "AsrInfo.h"
- #include "Util.h"
- #include <json/json.h>
- AsrInfo::AsrInfo()
- {
- __reset();
- }
- AsrInfo::~AsrInfo()
- {
- __reset();
- }
- void AsrInfo::setCallInfo(const std::string&strCallID,const std::string & strCaller, const std::string & strCalled, const std::string & strDirection, const std::string & strVocDirect)
- {
- callStartTime = GetUnixTime();
- callID = strCallID;
- caller = strCaller;
- called = strCalled;
- direction = strDirection;
- vocDirect = strVocDirect;
- }
- void AsrInfo::setSentenceBeginTime()
- {
- sentenceBeginTime = GetUnixTime() - callStartTime;
- }
- void AsrInfo::setTransSentenceText(const std::string&strTransText, const std::int32_t&nIndex)
- {
- createTime = GetUnixTime();
- transSentenceTime = createTime - callStartTime;
- transSentenceText = strTransText;
- transSentenceIndex = nIndex;
- }
- std::string AsrInfo::asrInfo()
- {
- Json::Value root;
- root["callID"] = callID;
- root["callStartTime"] = callStartTime;
- root["agent"] = agent;
- root["caller"] = caller;
- root["called"] = called;
- root["direction"] = direction;
- root["vocDirect"] = vocDirect;
- root["sentenceBeginTime"] = sentenceBeginTime;
- root["createTime"] = createTime;
- root["transSentenceTime"] = transSentenceTime;
- root["transSentenceText"] = transSentenceText;
- root["transSentenceIndex"] = transSentenceIndex;
- Json::StreamWriterBuilder builder;
-
- return Json::writeString(builder, root);
- }
- void AsrInfo::__reset()
- {
- callID = "";
- callStartTime = 0;
- caller = "";
- called = "";
- direction = "";
- vocDirect = "";
- createTime = 0;
- sentenceBeginTime = 0;
- transSentenceText = "";
- transSentenceIndex = 0;
- transSentenceTime = 0;
- }
|