Add Python API (#31)

This commit is contained in:
Fangjun Kuang
2023-02-19 19:36:03 +08:00
committed by GitHub
parent 8acc059b3f
commit ea09d5fbc5
51 changed files with 967 additions and 57 deletions

View File

@@ -0,0 +1,21 @@
// sherpa-onnx/python/csrc/online-stream.cc
//
// Copyright (c) 2023 Xiaomi Corporation
#include "sherpa-onnx/python/csrc/online-stream.h"
#include "sherpa-onnx/csrc/online-stream.h"
namespace sherpa_onnx {
void PybindOnlineStream(py::module *m) {
using PyClass = OnlineStream;
py::class_<PyClass>(*m, "OnlineStream")
.def("accept_waveform",
[](PyClass &self, float sample_rate, py::array_t<float> waveform) {
self.AcceptWaveform(sample_rate, waveform.data(), waveform.size());
})
.def("input_finished", &PyClass::InputFinished);
}
} // namespace sherpa_onnx