Support adding punctuations to the speech recogntion result (#761)
This commit is contained in:
42
sherpa-onnx/csrc/offline-punctuation.cc
Normal file
42
sherpa-onnx/csrc/offline-punctuation.cc
Normal file
@@ -0,0 +1,42 @@
|
||||
// sherpa-onnx/csrc/offline-punctuation.cc
|
||||
//
|
||||
// Copyright (c) 2024 Xiaomi Corporation
|
||||
|
||||
#include "sherpa-onnx/csrc/offline-punctuation.h"
|
||||
|
||||
#include "sherpa-onnx/csrc/macros.h"
|
||||
#include "sherpa-onnx/csrc/offline-punctuation-impl.h"
|
||||
|
||||
namespace sherpa_onnx {
|
||||
|
||||
void OfflinePunctuationConfig::Register(ParseOptions *po) {
|
||||
model.Register(po);
|
||||
}
|
||||
|
||||
bool OfflinePunctuationConfig::Validate() const {
|
||||
if (!model.Validate()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string OfflinePunctuationConfig::ToString() const {
|
||||
std::ostringstream os;
|
||||
|
||||
os << "OfflinePunctuationConfig(";
|
||||
os << "model=" << model.ToString() << ")";
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
||||
OfflinePunctuation::OfflinePunctuation(const OfflinePunctuationConfig &config)
|
||||
: impl_(OfflinePunctuationImpl::Create(config)) {}
|
||||
|
||||
OfflinePunctuation::~OfflinePunctuation() = default;
|
||||
|
||||
std::string OfflinePunctuation::AddPunctuation(const std::string &text) const {
|
||||
return impl_->AddPunctuation(text);
|
||||
}
|
||||
|
||||
} // namespace sherpa_onnx
|
||||
Reference in New Issue
Block a user