| | |
| | | } |
| | | |
| | | // offline |
| | | void Paraformer::InitAsr(const std::string &am_model, const std::string &am_cmvn, const std::string &am_config, int thread_num){ |
| | | void Paraformer::InitAsr(const std::string &am_model, const std::string &am_cmvn, const std::string &am_config, const std::string &token_file, int thread_num){ |
| | | LoadConfigFromYaml(am_config.c_str()); |
| | | // knf options |
| | | fbank_opts_.frame_opts.dither = 0; |
| | |
| | | exit(-1); |
| | | } |
| | | |
| | | string strName; |
| | | GetInputName(m_session_.get(), strName); |
| | | m_strInputNames.push_back(strName.c_str()); |
| | | GetInputName(m_session_.get(), strName,1); |
| | | m_strInputNames.push_back(strName); |
| | | if (use_hotword) { |
| | | GetInputName(m_session_.get(), strName, 2); |
| | | m_strInputNames.push_back(strName); |
| | | } |
| | | |
| | | size_t numOutputNodes = m_session_->GetOutputCount(); |
| | | for(int index=0; index<numOutputNodes; index++){ |
| | | GetOutputName(m_session_.get(), strName, index); |
| | | m_strOutputNames.push_back(strName); |
| | | } |
| | | |
| | | for (auto& item : m_strInputNames) |
| | | m_szInputNames.push_back(item.c_str()); |
| | | for (auto& item : m_strOutputNames) |
| | | m_szOutputNames.push_back(item.c_str()); |
| | | vocab = new Vocab(am_config.c_str()); |
| | | phone_set_ = new PhoneSet(am_config.c_str()); |
| | | GetInputNames(m_session_.get(), m_strInputNames, m_szInputNames); |
| | | GetOutputNames(m_session_.get(), m_strOutputNames, m_szOutputNames); |
| | | vocab = new Vocab(token_file.c_str()); |
| | | phone_set_ = new PhoneSet(token_file.c_str()); |
| | | LoadCmvn(am_cmvn.c_str()); |
| | | } |
| | | |
| | | // online |
| | | void Paraformer::InitAsr(const std::string &en_model, const std::string &de_model, const std::string &am_cmvn, const std::string &am_config, int thread_num){ |
| | | void Paraformer::InitAsr(const std::string &en_model, const std::string &de_model, const std::string &am_cmvn, const std::string &am_config, const std::string &token_file, int thread_num){ |
| | | |
| | | LoadOnlineConfigFromYaml(am_config.c_str()); |
| | | // knf options |
| | |
| | | for (auto& item : de_strOutputNames) |
| | | de_szOutputNames_.push_back(item.c_str()); |
| | | |
| | | vocab = new Vocab(am_config.c_str()); |
| | | phone_set_ = new PhoneSet(am_config.c_str()); |
| | | vocab = new Vocab(token_file.c_str()); |
| | | phone_set_ = new PhoneSet(token_file.c_str()); |
| | | LoadCmvn(am_cmvn.c_str()); |
| | | } |
| | | |
| | | // 2pass |
| | | void Paraformer::InitAsr(const std::string &am_model, const std::string &en_model, const std::string &de_model, const std::string &am_cmvn, const std::string &am_config, int thread_num){ |
| | | void Paraformer::InitAsr(const std::string &am_model, const std::string &en_model, const std::string &de_model, |
| | | const std::string &am_cmvn, const std::string &am_config, const std::string &token_file, const std::string &online_token_file, int thread_num){ |
| | | // online |
| | | InitAsr(en_model, de_model, am_cmvn, am_config, thread_num); |
| | | InitAsr(en_model, de_model, am_cmvn, am_config, online_token_file, thread_num); |
| | | |
| | | // offline |
| | | try { |
| | |
| | | exit(-1); |
| | | } |
| | | |
| | | string strName; |
| | | GetInputName(m_session_.get(), strName); |
| | | m_strInputNames.push_back(strName.c_str()); |
| | | GetInputName(m_session_.get(), strName,1); |
| | | m_strInputNames.push_back(strName); |
| | | |
| | | if (use_hotword) { |
| | | GetInputName(m_session_.get(), strName, 2); |
| | | m_strInputNames.push_back(strName); |
| | | } |
| | | |
| | | // support time stamp |
| | | size_t numOutputNodes = m_session_->GetOutputCount(); |
| | | for(int index=0; index<numOutputNodes; index++){ |
| | | GetOutputName(m_session_.get(), strName, index); |
| | | m_strOutputNames.push_back(strName); |
| | | } |
| | | |
| | | for (auto& item : m_strInputNames) |
| | | m_szInputNames.push_back(item.c_str()); |
| | | for (auto& item : m_strOutputNames) |
| | | m_szOutputNames.push_back(item.c_str()); |
| | | GetInputNames(m_session_.get(), m_strInputNames, m_szInputNames); |
| | | GetOutputNames(m_session_.get(), m_strOutputNames, m_szOutputNames); |
| | | } |
| | | |
| | | void Paraformer::InitLm(const std::string &lm_file, |