* Support streaming zipformer CTC * test online zipformer2 CTC * Update doc of sherpa-onnx.cc * Add Python APIs for streaming zipformer2 ctc * Add Python API examples for streaming zipformer2 ctc * Swift API for streaming zipformer2 CTC * NodeJS API for streaming zipformer2 CTC * Kotlin API for streaming zipformer2 CTC * Golang API for streaming zipformer2 CTC * C# API for streaming zipformer2 CTC * Release v1.9.6
54 lines
1.6 KiB
C++
54 lines
1.6 KiB
C++
// sherpa-onnx/csrc/online-recognizer-impl.cc
|
|
//
|
|
// Copyright (c) 2023 Xiaomi Corporation
|
|
|
|
#include "sherpa-onnx/csrc/online-recognizer-impl.h"
|
|
|
|
#include "sherpa-onnx/csrc/online-recognizer-ctc-impl.h"
|
|
#include "sherpa-onnx/csrc/online-recognizer-paraformer-impl.h"
|
|
#include "sherpa-onnx/csrc/online-recognizer-transducer-impl.h"
|
|
|
|
namespace sherpa_onnx {
|
|
|
|
std::unique_ptr<OnlineRecognizerImpl> OnlineRecognizerImpl::Create(
|
|
const OnlineRecognizerConfig &config) {
|
|
if (!config.model_config.transducer.encoder.empty()) {
|
|
return std::make_unique<OnlineRecognizerTransducerImpl>(config);
|
|
}
|
|
|
|
if (!config.model_config.paraformer.encoder.empty()) {
|
|
return std::make_unique<OnlineRecognizerParaformerImpl>(config);
|
|
}
|
|
|
|
if (!config.model_config.wenet_ctc.model.empty() ||
|
|
!config.model_config.zipformer2_ctc.model.empty()) {
|
|
return std::make_unique<OnlineRecognizerCtcImpl>(config);
|
|
}
|
|
|
|
SHERPA_ONNX_LOGE("Please specify a model");
|
|
exit(-1);
|
|
}
|
|
|
|
#if __ANDROID_API__ >= 9
|
|
std::unique_ptr<OnlineRecognizerImpl> OnlineRecognizerImpl::Create(
|
|
AAssetManager *mgr, const OnlineRecognizerConfig &config) {
|
|
if (!config.model_config.transducer.encoder.empty()) {
|
|
return std::make_unique<OnlineRecognizerTransducerImpl>(mgr, config);
|
|
}
|
|
|
|
if (!config.model_config.paraformer.encoder.empty()) {
|
|
return std::make_unique<OnlineRecognizerParaformerImpl>(mgr, config);
|
|
}
|
|
|
|
if (!config.model_config.wenet_ctc.model.empty() ||
|
|
!config.model_config.zipformer2_ctc.model.empty()) {
|
|
return std::make_unique<OnlineRecognizerCtcImpl>(mgr, config);
|
|
}
|
|
|
|
SHERPA_ONNX_LOGE("Please specify a model");
|
|
exit(-1);
|
|
}
|
|
#endif
|
|
|
|
} // namespace sherpa_onnx
|