online-punctuation.cc
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// sherpa-onnx/csrc/online-punctuation.cc
//
// Copyright (c) 2024 Jian You (jianyou@cisco.com, Cisco Systems)
#include "sherpa-onnx/csrc/online-punctuation.h"
#if __ANDROID_API__ >= 9
#include "android/asset_manager.h"
#include "android/asset_manager_jni.h"
#endif
#include "sherpa-onnx/csrc/macros.h"
#include "sherpa-onnx/csrc/online-punctuation-impl.h"
namespace sherpa_onnx {
void OnlinePunctuationConfig::Register(ParseOptions *po) {
model.Register(po);
}
bool OnlinePunctuationConfig::Validate() const {
if (!model.Validate()) {
return false;
}
return true;
}
std::string OnlinePunctuationConfig::ToString() const {
std::ostringstream os;
os << "OnlinePunctuationConfig(";
os << "model=" << model.ToString() << ")";
return os.str();
}
OnlinePunctuation::OnlinePunctuation(const OnlinePunctuationConfig &config)
: impl_(OnlinePunctuationImpl::Create(config)) {}
#if __ANDROID_API__ >= 9
OnlinePunctuation::OnlinePunctuation(AAssetManager *mgr,
const OnlinePunctuationConfig &config)
: impl_(OnlinePunctuationImpl::Create(mgr, config)) {}
#endif
OnlinePunctuation::~OnlinePunctuation() = default;
std::string OnlinePunctuation::AddPunctuationWithCase(const std::string &text) const {
return impl_->AddPunctuationWithCase(text);
}
} // namespace sherpa_onnx