hnluo
2023-09-21 41c64e4729ca359f7212534055239c8289b5e2f4
funasr/runtime/onnxruntime/src/tpass-stream.cpp
@@ -36,6 +36,20 @@
        string de_model_path;
        string am_cmvn_path;
        string am_config_path;
        string hw_compile_model_path;
        string seg_dict_path;
        asr_handle = make_unique<Paraformer>();
        bool enable_hotword = false;
        hw_compile_model_path = PathAppend(model_path.at(MODEL_DIR), MODEL_EB_NAME);
        seg_dict_path = PathAppend(model_path.at(MODEL_DIR), MODEL_SEG_DICT);
        if ((access(hw_compile_model_path.c_str(), F_OK) == 0) &&
            (access(seg_dict_path.c_str(), F_OK) == 0)) { // if model_eb.onnx exist, hotword enabled
          enable_hotword = true;
          asr_handle->InitHwCompiler(hw_compile_model_path, thread_num);
          asr_handle->InitSegDict(seg_dict_path);
        }
        am_model_path = PathAppend(model_path.at(OFFLINE_MODEL_DIR), MODEL_NAME);
        en_model_path = PathAppend(model_path.at(ONLINE_MODEL_DIR), ENCODER_NAME);
@@ -48,7 +62,6 @@
        am_cmvn_path = PathAppend(model_path.at(ONLINE_MODEL_DIR), AM_CMVN_NAME);
        am_config_path = PathAppend(model_path.at(ONLINE_MODEL_DIR), AM_CONFIG_NAME);
        asr_handle = make_unique<Paraformer>();
        asr_handle->InitAsr(am_model_path, en_model_path, de_model_path, am_cmvn_path, am_config_path, thread_num);
    }else{
        LOG(ERROR) <<"Can not find offline-model-dir or online-model-dir";
@@ -76,6 +89,24 @@
            use_punc = true;
        }
    }
#if !defined(__APPLE__)
    // Optional: ITN, here we just support language_type=MandarinEnglish
    if(model_path.find(ITN_DIR) != model_path.end()){
        string itn_tagger_path = PathAppend(model_path.at(ITN_DIR), ITN_TAGGER_NAME);
        string itn_verbalizer_path = PathAppend(model_path.at(ITN_DIR), ITN_VERBALIZER_NAME);
        if (access(itn_tagger_path.c_str(), F_OK) != 0 ||
            access(itn_verbalizer_path.c_str(), F_OK) != 0 )
        {
            LOG(INFO) << "ITN model file is not exist, skip load ITN model.";
        }else{
            itn_handle = make_unique<ITNProcessor>();
            itn_handle->InitITN(itn_tagger_path, itn_verbalizer_path, thread_num);
            use_itn = true;
        }
    }
#endif
}
TpassStream *CreateTpassStream(std::map<std::string, std::string>& model_path, int thread_num)
@@ -84,4 +115,4 @@
    mm = new TpassStream(model_path, thread_num);
    return mm;
}
} // namespace funasr
} // namespace funasr