diff --git a/sherpa-onnx/csrc/online-websocket-server-impl.cc b/sherpa-onnx/csrc/online-websocket-server-impl.cc index eaf65cfa9..a47e613c8 100644 --- a/sherpa-onnx/csrc/online-websocket-server-impl.cc +++ b/sherpa-onnx/csrc/online-websocket-server-impl.cc @@ -304,7 +304,10 @@ void OnlineWebsocketServer::OnMessage(connection_hdl hdl, int32_t num_samples = payload.size() / sizeof(float); std::vector samples(p, p + num_samples); - c->samples.push_back(std::move(samples)); + { + std::lock_guard lock(c->mutex); + c->samples.push_back(std::move(samples)); + } asio::post(io_work_, [this, c]() { decoder_.AcceptWaveform(c); }); break;