online-ctc-fst-decoder.h
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
// sherpa-onnx/csrc/online-ctc-fst-decoder.h
//
// Copyright (c) 2024 Xiaomi Corporation
#ifndef SHERPA_ONNX_CSRC_ONLINE_CTC_FST_DECODER_H_
#define SHERPA_ONNX_CSRC_ONLINE_CTC_FST_DECODER_H_
#include <memory>
#include <vector>
#include "fst/fst.h"
#include "sherpa-onnx/csrc/online-ctc-decoder.h"
#include "sherpa-onnx/csrc/online-ctc-fst-decoder-config.h"
namespace sherpa_onnx {
class OnlineCtcFstDecoder : public OnlineCtcDecoder {
public:
OnlineCtcFstDecoder(const OnlineCtcFstDecoderConfig &config,
int32_t blank_id);
void Decode(const float *log_probs, int32_t batch_size, int32_t num_frames,
int32_t vocab_size, std::vector<OnlineCtcDecoderResult> *results,
OnlineStream **ss = nullptr, int32_t n = 0) override;
std::unique_ptr<kaldi_decoder::FasterDecoder> CreateFasterDecoder()
const override;
private:
OnlineCtcFstDecoderConfig config_;
kaldi_decoder::FasterDecoderOptions options_;
std::unique_ptr<fst::Fst<fst::StdArc>> fst_;
int32_t blank_id_ = 0;
};
} // namespace sherpa_onnx
#endif // SHERPA_ONNX_CSRC_ONLINE_CTC_FST_DECODER_H_