online-paraformer-model.h
2.0 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// sherpa-onnx/csrc/online-paraformer-model.h
//
// Copyright (c) 2022-2023 Xiaomi Corporation
#ifndef SHERPA_ONNX_CSRC_ONLINE_PARAFORMER_MODEL_H_
#define SHERPA_ONNX_CSRC_ONLINE_PARAFORMER_MODEL_H_
#include <memory>
#include <utility>
#include <vector>
#if __ANDROID_API__ >= 9
#include "android/asset_manager.h"
#include "android/asset_manager_jni.h"
#endif
#include "onnxruntime_cxx_api.h" // NOLINT
#include "sherpa-onnx/csrc/online-model-config.h"
namespace sherpa_onnx {
class OnlineParaformerModel {
public:
explicit OnlineParaformerModel(const OnlineModelConfig &config);
#if __ANDROID_API__ >= 9
OnlineParaformerModel(AAssetManager *mgr, const OnlineModelConfig &config);
#endif
~OnlineParaformerModel();
std::vector<Ort::Value> ForwardEncoder(Ort::Value features,
Ort::Value features_length) const;
std::vector<Ort::Value> ForwardDecoder(Ort::Value encoder_out,
Ort::Value encoder_out_length,
Ort::Value acoustic_embedding,
Ort::Value acoustic_embedding_length,
std::vector<Ort::Value> states) const;
/** Return the vocabulary size of the model
*/
int32_t VocabSize() const;
/** It is lfr_m in config.yaml
*/
int32_t LfrWindowSize() const;
/** It is lfr_n in config.yaml
*/
int32_t LfrWindowShift() const;
int32_t EncoderOutputSize() const;
int32_t DecoderKernelSize() const;
int32_t DecoderNumBlocks() const;
/** Return negative mean for CMVN
*/
const std::vector<float> &NegativeMean() const;
/** Return inverse stddev for CMVN
*/
const std::vector<float> &InverseStdDev() const;
/** Return an allocator for allocating memory
*/
OrtAllocator *Allocator() const;
private:
class Impl;
std::unique_ptr<Impl> impl_;
};
} // namespace sherpa_onnx
#endif // SHERPA_ONNX_CSRC_ONLINE_PARAFORMER_MODEL_H_