From 6b3d2b87f9a780e774400d5065a5d44b73c1a3eb Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Mon, 8 Apr 2024 17:22:48 +0800 Subject: [PATCH] Fix releasing GIL (#741) --- sherpa-onnx/python/csrc/offline-stream.cc | 13 ++----------- sherpa-onnx/python/csrc/online-stream.cc | 3 ++- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/sherpa-onnx/python/csrc/offline-stream.cc b/sherpa-onnx/python/csrc/offline-stream.cc index bd1d0650..32c6e414 100644 --- a/sherpa-onnx/python/csrc/offline-stream.cc +++ b/sherpa-onnx/python/csrc/offline-stream.cc @@ -53,17 +53,8 @@ void PybindOfflineStream(py::module *m) { py::class_(*m, "OfflineStream") .def( "accept_waveform", - [](PyClass &self, float sample_rate, py::array_t waveform) { -#if 0 - auto report_gil_status = []() { - auto is_gil_held = false; - if (auto tstate = py::detail::get_thread_state_unchecked()) - is_gil_held = (tstate == PyGILState_GetThisThreadState()); - - return is_gil_held ? "GIL held" : "GIL released"; - }; - std::cout << report_gil_status() << "\n"; -#endif + [](PyClass &self, float sample_rate, + const std::vector &waveform) { self.AcceptWaveform(sample_rate, waveform.data(), waveform.size()); }, py::arg("sample_rate"), py::arg("waveform"), kAcceptWaveformUsage, diff --git a/sherpa-onnx/python/csrc/online-stream.cc b/sherpa-onnx/python/csrc/online-stream.cc index 9f8a17b9..20800065 100644 --- a/sherpa-onnx/python/csrc/online-stream.cc +++ b/sherpa-onnx/python/csrc/online-stream.cc @@ -25,7 +25,8 @@ void PybindOnlineStream(py::module *m) { py::class_(*m, "OnlineStream") .def( "accept_waveform", - [](PyClass &self, float sample_rate, py::array_t waveform) { + [](PyClass &self, float sample_rate, + const std::vector &waveform) { self.AcceptWaveform(sample_rate, waveform.data(), waveform.size()); }, py::arg("sample_rate"), py::arg("waveform"), kAcceptWaveformUsage,