This commit is contained in:
wangjiyu 2025-04-10 22:08:45 +08:00
parent 0f7c98f2f2
commit f37404204c
1 changed files with 5 additions and 0 deletions

View File

@ -213,10 +213,13 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
// 5. 构建参数元组
std::cout << "[6] 构建参数元组..." << std::endl;
PyObject* py_dims = PyTuple_New(1);
std::cout << "step1, " << py_dims << std::endl;
PyTuple_SetItem(py_dims, 0, PyLong_FromLong(dims[0]));
std::cout << "step2" << std::endl;
// 修正点显式处理dtype类型转换
PyArray_Descr* np_dtype = PyArray_DescrFromType(NPY_INT16);
std::cout << "step3" << std::endl;
if (!np_dtype) {
Py_DECREF(py_dims);
Py_DECREF(empty_func);
@ -225,7 +228,9 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
PyGILState_Release(gstate);
throw std::runtime_error("Failed to create numpy dtype");
}
std::cout << "step4" << std::endl;
PyObject* dtype = reinterpret_cast<PyObject*>(np_dtype);
std::cout << "step5" << std::endl;
PyObject* args = PyTuple_Pack(2, py_dims, dtype);
std::cout << " 参数构建完成: " << args << std::endl;