| | |
| | | nlohmann::json jsonresult; // result json
|
| | | jsonresult["text"] = asr_result; // put result in 'text'
|
| | | jsonresult["mode"] = "offline";
|
| | | jsonresult["is_final"] = false;
|
| | | if(stamp_res != ""){
|
| | | jsonresult["timestamp"] = stamp_res;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | LOG(INFO) << "buffer.size=" << buffer.size() << ",result json=" << jsonresult.dump();
|
| | | }else{
|
| | | LOG(INFO) << "Sent empty meg";
|
| | | websocketpp::lib::error_code ec;
|
| | | nlohmann::json jsonresult; // result json
|
| | | jsonresult["text"] = ""; // put result in 'text'
|
| | | jsonresult["mode"] = "offline";
|
| | | jsonresult["is_final"] = false;
|
| | | jsonresult["wav_name"] = wav_name;
|
| | |
|
| | | // send the json to client
|
| | | if (is_ssl) {
|
| | | wss_server_->send(hdl, jsonresult.dump(),
|
| | | websocketpp::frame::opcode::text, ec);
|
| | | } else {
|
| | | server_->send(hdl, jsonresult.dump(), websocketpp::frame::opcode::text,
|
| | | ec);
|
| | | }
|
| | | }
|
| | |
|
| | | } catch (std::exception const& e) {
|
| | |
| | | unique_lock guard_decoder(*(data_msg->thread_lock));
|
| | | data_msg->msg["is_eof"]=true;
|
| | | guard_decoder.unlock();
|
| | | // data_map.erase(hdl); // remove data vector when connection is closed
|
| | |
|
| | | LOG(INFO) << "on_close, active connections: " << data_map.size();
|
| | | }
|
| | |
| | | websocketpp::connection_hdl hdl,
|
| | | std::map<websocketpp::connection_hdl, std::shared_ptr<FUNASR_MESSAGE>,
|
| | | std::owner_less<websocketpp::connection_hdl>>& data_map) {
|
| | | |
| | | std::shared_ptr<FUNASR_MESSAGE> data_msg = nullptr;
|
| | | auto it_data = data_map.find(hdl);
|
| | | if (it_data != data_map.end()) {
|
| | |
| | | iter++;
|
| | | }
|
| | | for (auto hdl : to_remove) {
|
| | | remove_hdl(hdl, data_map);
|
| | | //LOG(INFO) << "remove one connection ";
|
| | | {
|
| | | unique_lock lock(m_lock);
|
| | | remove_hdl(hdl, data_map);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | auto it_data = data_map.find(hdl);
|
| | | if (it_data != data_map.end()) {
|
| | | msg_data = it_data->second;
|
| | | } else{
|
| | | lock.unlock();
|
| | | return;
|
| | | }
|
| | |
|
| | | std::shared_ptr<std::vector<char>> sample_data_p = msg_data->samples;
|
| | | std::shared_ptr<websocketpp::lib::mutex> thread_lock_p = msg_data->thread_lock;
|
| | |
|