offline-ctc-fst-decoder-config.cc
1.1 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
// sherpa-onnx/csrc/offline-ctc-fst-decoder-config.cc
//
// Copyright (c) 2023 Xiaomi Corporation
#include "sherpa-onnx/csrc/offline-ctc-fst-decoder-config.h"
#include <sstream>
#include <string>
#include "sherpa-onnx/csrc/file-utils.h"
#include "sherpa-onnx/csrc/macros.h"
namespace sherpa_onnx {
std::string OfflineCtcFstDecoderConfig::ToString() const {
std::ostringstream os;
os << "OfflineCtcFstDecoderConfig(";
os << "graph=\"" << graph << "\", ";
os << "max_active=" << max_active << ")";
return os.str();
}
void OfflineCtcFstDecoderConfig::Register(ParseOptions *po) {
std::string prefix = "ctc";
ParseOptions p(prefix, po);
p.Register("graph", &graph, "Path to H.fst, HL.fst, or HLG.fst");
p.Register("max-active", &max_active,
"Decoder max active states. Larger->slower; more accurate");
}
bool OfflineCtcFstDecoderConfig::Validate() const {
if (!graph.empty() && !FileExists(graph)) {
SHERPA_ONNX_LOGE("graph: %s does not exist", graph.c_str());
return false;
}
return true;
}
} // namespace sherpa_onnx