This repository has been archived on 2025-08-26. You can view files and clone it, but cannot push or open issues or pull requests.
Files
enginex-mr_series-sherpa-onnx/sherpa-onnx/csrc/online-transducer-model-config.h

59 lines
1.7 KiB
C
Raw Normal View History

2023-02-19 19:36:03 +08:00
// sherpa-onnx/csrc/online-transducer-model-config.h
2023-02-18 21:35:15 +08:00
//
// Copyright (c) 2023 Xiaomi Corporation
#ifndef SHERPA_ONNX_CSRC_ONLINE_TRANSDUCER_MODEL_CONFIG_H_
#define SHERPA_ONNX_CSRC_ONLINE_TRANSDUCER_MODEL_CONFIG_H_
#include <string>
#include "sherpa-onnx/csrc/parse-options.h"
2023-02-18 21:35:15 +08:00
namespace sherpa_onnx {
struct OnlineTransducerModelConfig {
std::string encoder_filename;
std::string decoder_filename;
std::string joiner_filename;
2023-02-24 13:57:03 +08:00
std::string tokens;
int32_t num_threads = 2;
2023-02-18 21:35:15 +08:00
bool debug = false;
2023-05-12 15:57:44 +08:00
std::string provider = "cpu";
2023-02-18 21:35:15 +08:00
// With the help of this field, we only need to load the model once
// instead of twice; and therefore it reduces initialization time.
//
// Valid values:
// - conformer
// - lstm
// - zipformer
// - zipformer2
//
// All other values are invalid and lead to loading the model twice.
std::string model_type;
2023-02-19 19:36:03 +08:00
OnlineTransducerModelConfig() = default;
OnlineTransducerModelConfig(const std::string &encoder_filename,
const std::string &decoder_filename,
const std::string &joiner_filename,
2023-02-24 13:57:03 +08:00
const std::string &tokens, int32_t num_threads,
bool debug, const std::string &provider,
const std::string &model_type)
2023-02-19 19:36:03 +08:00
: encoder_filename(encoder_filename),
decoder_filename(decoder_filename),
joiner_filename(joiner_filename),
2023-02-24 13:57:03 +08:00
tokens(tokens),
2023-02-19 19:36:03 +08:00
num_threads(num_threads),
2023-05-12 15:57:44 +08:00
debug(debug),
provider(provider),
model_type(model_type) {}
2023-02-19 19:36:03 +08:00
void Register(ParseOptions *po);
bool Validate() const;
2023-02-18 21:35:15 +08:00
std::string ToString() const;
};
} // namespace sherpa_onnx
#endif // SHERPA_ONNX_CSRC_ONLINE_TRANSDUCER_MODEL_CONFIG_H_