#include "Util.h" #include #include #include "tinyxml.h" /* 也不准确。 2420 3540 fba26d3861574ac4b55c01f4881c5bae b3f91c673b9146b7-7.wav 也不准确。 */ bool parseASRXml(const char* desc, std::string& result, std::string& error) { try{ TiXmlDocument doc; doc.Parse(desc); auto pRoot = doc.RootElement(); if (pRoot != nullptr && pRoot->ValueStr() == "result") { auto pElement = pRoot->FirstChildElement("interpretation"); if (pElement) { auto pInput = pElement->FirstChildElement("input"); if (pInput) { auto pText = pInput->GetText(); result = pText != nullptr ? pText : ""; return true; } } } } catch (const std::exception& e){ error = e.what(); } return false; } int64_t GetUnixTime() { int64_t times = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); return times; } std::string std::to_string(const char * src) { if (src == nullptr)return ""; std::stringstream ss; ss << src; std::string str; ss >> str; return str; }