Add Python API for source separation (#2283)

This commit is contained in:
Fangjun Kuang
2025-06-05 20:44:26 +08:00
committed by GitHub
parent 6f0fac2064
commit d57e4f84de
20 changed files with 599 additions and 23 deletions

View File

@@ -9,6 +9,8 @@
#include "sherpa-onnx/csrc/fast-clustering.h"
#define C_CONTIGUOUS py::detail::npy_api::constants::NPY_ARRAY_C_CONTIGUOUS_
namespace sherpa_onnx {
static void PybindFastClusteringConfig(py::module *m) {
@@ -32,6 +34,12 @@ void PybindFastClustering(py::module *m) {
"__call__",
[](const PyClass &self,
py::array_t<float> features) -> std::vector<int32_t> {
if (!(C_CONTIGUOUS == (features.flags() & C_CONTIGUOUS))) {
throw py::value_error(
"input features should be contiguous. Please use "
"np.ascontiguousarray(features)");
}
int num_dim = features.ndim();
if (num_dim != 2) {
std::ostringstream os;