MCPcopy Create free account
hub / github.com/aarnphm/whispercpp / as_pyarray

Function as_pyarray

src/whispercpp/api_cpp2py_export.h:53–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51// See https://github.com/pybind/pybind11/issues/1042#issuecomment-642215028
52template <typename Sequence>
53inline py::array_t<typename Sequence::value_type> as_pyarray(Sequence &&seq) {
54 auto size = seq.size();
55 auto data = seq.data();
56 std::unique_ptr<Sequence> seq_ptr =
57 whisper::make_unique<Sequence>(std::move(seq));
58 auto capsule = py::capsule(seq_ptr.get(), [](void *p) {
59 std::unique_ptr<Sequence>(reinterpret_cast<Sequence *>(p));
60 });
61 seq_ptr.release();
62 return py::array(size, data, capsule);
63}
64} // namespace whisper
65
66struct WavFileWrapper {

Callers 1

WavFileWrapperMethod · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected