2023-08-09 20:27:31 +08:00
|
|
|
// sherpa-onnx/python/csrc/online-model-config.cc
|
|
|
|
|
//
|
2023-08-14 10:32:14 +08:00
|
|
|
// Copyright (c) 2023 Xiaomi Corporation
|
2023-08-09 20:27:31 +08:00
|
|
|
|
|
|
|
|
#include "sherpa-onnx/python/csrc/online-model-config.h"
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "sherpa-onnx/csrc/online-model-config.h"
|
|
|
|
|
#include "sherpa-onnx/csrc/online-transducer-model-config.h"
|
2024-07-05 12:48:37 +05:30
|
|
|
#include "sherpa-onnx/csrc/provider-config.h"
|
2024-05-10 16:26:43 +08:00
|
|
|
#include "sherpa-onnx/python/csrc/online-nemo-ctc-model-config.h"
|
2023-08-14 10:32:14 +08:00
|
|
|
#include "sherpa-onnx/python/csrc/online-paraformer-model-config.h"
|
2023-08-09 20:27:31 +08:00
|
|
|
#include "sherpa-onnx/python/csrc/online-transducer-model-config.h"
|
2023-11-16 10:35:23 +08:00
|
|
|
#include "sherpa-onnx/python/csrc/online-wenet-ctc-model-config.h"
|
2023-12-22 13:46:33 +08:00
|
|
|
#include "sherpa-onnx/python/csrc/online-zipformer2-ctc-model-config.h"
|
2024-07-05 12:48:37 +05:30
|
|
|
#include "sherpa-onnx/python/csrc/provider-config.h"
|
2023-08-09 20:27:31 +08:00
|
|
|
|
|
|
|
|
namespace sherpa_onnx {
|
|
|
|
|
|
|
|
|
|
void PybindOnlineModelConfig(py::module *m) {
|
|
|
|
|
PybindOnlineTransducerModelConfig(m);
|
2023-08-14 10:32:14 +08:00
|
|
|
PybindOnlineParaformerModelConfig(m);
|
2023-11-16 10:35:23 +08:00
|
|
|
PybindOnlineWenetCtcModelConfig(m);
|
2023-12-22 13:46:33 +08:00
|
|
|
PybindOnlineZipformer2CtcModelConfig(m);
|
2024-05-10 16:26:43 +08:00
|
|
|
PybindOnlineNeMoCtcModelConfig(m);
|
2024-07-05 12:48:37 +05:30
|
|
|
PybindProviderConfig(m);
|
2023-08-09 20:27:31 +08:00
|
|
|
|
|
|
|
|
using PyClass = OnlineModelConfig;
|
|
|
|
|
py::class_<PyClass>(*m, "OnlineModelConfig")
|
2023-08-14 10:32:14 +08:00
|
|
|
.def(py::init<const OnlineTransducerModelConfig &,
|
2023-11-16 10:35:23 +08:00
|
|
|
const OnlineParaformerModelConfig &,
|
2023-12-22 13:46:33 +08:00
|
|
|
const OnlineWenetCtcModelConfig &,
|
2024-05-10 16:26:43 +08:00
|
|
|
const OnlineZipformer2CtcModelConfig &,
|
2024-07-05 12:48:37 +05:30
|
|
|
const OnlineNeMoCtcModelConfig &,
|
|
|
|
|
const ProviderConfig &,
|
|
|
|
|
const std::string &, int32_t, int32_t,
|
|
|
|
|
bool, const std::string &, const std::string &,
|
2024-04-16 09:46:15 +08:00
|
|
|
const std::string &>(),
|
2023-08-09 20:27:31 +08:00
|
|
|
py::arg("transducer") = OnlineTransducerModelConfig(),
|
2023-08-14 10:32:14 +08:00
|
|
|
py::arg("paraformer") = OnlineParaformerModelConfig(),
|
2023-11-16 10:35:23 +08:00
|
|
|
py::arg("wenet_ctc") = OnlineWenetCtcModelConfig(),
|
2023-12-22 13:46:33 +08:00
|
|
|
py::arg("zipformer2_ctc") = OnlineZipformer2CtcModelConfig(),
|
2024-07-05 12:48:37 +05:30
|
|
|
py::arg("nemo_ctc") = OnlineNeMoCtcModelConfig(),
|
|
|
|
|
py::arg("provider_config") = ProviderConfig(),
|
|
|
|
|
py::arg("tokens"), py::arg("num_threads"), py::arg("warm_up") = 0,
|
|
|
|
|
py::arg("debug") = false, py::arg("model_type") = "",
|
|
|
|
|
py::arg("modeling_unit") = "", py::arg("bpe_vocab") = "")
|
2023-08-09 20:27:31 +08:00
|
|
|
.def_readwrite("transducer", &PyClass::transducer)
|
2023-08-14 10:32:14 +08:00
|
|
|
.def_readwrite("paraformer", &PyClass::paraformer)
|
2023-11-16 10:35:23 +08:00
|
|
|
.def_readwrite("wenet_ctc", &PyClass::wenet_ctc)
|
2023-12-22 13:46:33 +08:00
|
|
|
.def_readwrite("zipformer2_ctc", &PyClass::zipformer2_ctc)
|
2024-05-10 16:26:43 +08:00
|
|
|
.def_readwrite("nemo_ctc", &PyClass::nemo_ctc)
|
2024-07-05 12:48:37 +05:30
|
|
|
.def_readwrite("provider_config", &PyClass::provider_config)
|
2023-08-09 20:27:31 +08:00
|
|
|
.def_readwrite("tokens", &PyClass::tokens)
|
|
|
|
|
.def_readwrite("num_threads", &PyClass::num_threads)
|
2024-07-05 12:48:37 +05:30
|
|
|
.def_readwrite("warm_up", &PyClass::warm_up)
|
2023-08-09 20:27:31 +08:00
|
|
|
.def_readwrite("debug", &PyClass::debug)
|
|
|
|
|
.def_readwrite("model_type", &PyClass::model_type)
|
2024-05-20 19:41:36 +08:00
|
|
|
.def_readwrite("modeling_unit", &PyClass::modeling_unit)
|
|
|
|
|
.def_readwrite("bpe_vocab", &PyClass::bpe_vocab)
|
2023-12-22 13:46:33 +08:00
|
|
|
.def("validate", &PyClass::Validate)
|
2023-08-09 20:27:31 +08:00
|
|
|
.def("__str__", &PyClass::ToString);
|
|
|
|
|
}
|
|
|
|
|
} // namespace sherpa_onnx
|