mirror of
https://github.com/modelscope/FunASR
synced 2025-09-15 14:48:36 +08:00
update cpp client
This commit is contained in:
parent
8b6aaac4ae
commit
263802e20d
@ -106,10 +106,10 @@ class WebsocketClient {
|
|||||||
const std::string& payload = msg->get_payload();
|
const std::string& payload = msg->get_payload();
|
||||||
switch (msg->get_opcode()) {
|
switch (msg->get_opcode()) {
|
||||||
case websocketpp::frame::opcode::text:
|
case websocketpp::frame::opcode::text:
|
||||||
total_num=total_num+1;
|
total_recv=total_recv+1;
|
||||||
LOG(INFO)<< "Thread: " << this_thread::get_id() <<",on_message = " << payload;
|
LOG(INFO)<< "Thread: " << this_thread::get_id() <<",on_message = " << payload;
|
||||||
LOG(INFO) << "total_num=" << total_num << " wav_index=" <<wav_index;
|
LOG(INFO) << "total_recv=" << total_recv << " total_send=" <<total_send;
|
||||||
if((total_num+1)==wav_index)
|
if(total_recv==total_send)
|
||||||
{
|
{
|
||||||
LOG(INFO) << "close client";
|
LOG(INFO) << "close client";
|
||||||
websocketpp::lib::error_code ec;
|
websocketpp::lib::error_code ec;
|
||||||
@ -149,6 +149,7 @@ class WebsocketClient {
|
|||||||
if (i >= wav_list.size()) {
|
if (i >= wav_list.size()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
total_send += 1;
|
||||||
send_wav_data(wav_list[i], wav_ids[i], hotwords, send_hotword);
|
send_wav_data(wav_list[i], wav_ids[i], hotwords, send_hotword);
|
||||||
if(send_hotword){
|
if(send_hotword){
|
||||||
send_hotword = false;
|
send_hotword = false;
|
||||||
@ -321,7 +322,7 @@ class WebsocketClient {
|
|||||||
jsonresult["is_speaking"] = false;
|
jsonresult["is_speaking"] = false;
|
||||||
m_client.send(m_hdl, jsonresult.dump(), websocketpp::frame::opcode::text,
|
m_client.send(m_hdl, jsonresult.dump(), websocketpp::frame::opcode::text,
|
||||||
ec);
|
ec);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||||
}
|
}
|
||||||
websocketpp::client<T> m_client;
|
websocketpp::client<T> m_client;
|
||||||
|
|
||||||
@ -330,7 +331,8 @@ class WebsocketClient {
|
|||||||
websocketpp::lib::mutex m_lock;
|
websocketpp::lib::mutex m_lock;
|
||||||
bool m_open;
|
bool m_open;
|
||||||
bool m_done;
|
bool m_done;
|
||||||
int total_num=0;
|
int total_send=0;
|
||||||
|
int total_recv=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user