chenmengzheAAA
2023-09-14 2a66366be4c2715870e4859fd5a5db6e8a9dc00a
funasr/runtime/onnxruntime/src/paraformer.cpp
@@ -41,7 +41,7 @@
        LOG(INFO) << "Successfully load model from " << am_model;
    } catch (std::exception const &e) {
        LOG(ERROR) << "Error when load am onnx model: " << e.what();
        exit(0);
        exit(-1);
    }
    string strName;
@@ -93,7 +93,7 @@
        LOG(INFO) << "Successfully load model from " << en_model;
    } catch (std::exception const &e) {
        LOG(ERROR) << "Error when load am encoder model: " << e.what();
        exit(0);
        exit(-1);
    }
    try {
@@ -101,7 +101,7 @@
        LOG(INFO) << "Successfully load model from " << de_model;
    } catch (std::exception const &e) {
        LOG(ERROR) << "Error when load am decoder model: " << e.what();
        exit(0);
        exit(-1);
    }
    // encoder
@@ -156,7 +156,7 @@
        LOG(INFO) << "Successfully load model from " << am_model;
    } catch (std::exception const &e) {
        LOG(ERROR) << "Error when load am onnx model: " << e.what();
        exit(0);
        exit(-1);
    }
    string strName;
@@ -225,7 +225,7 @@
        LOG(INFO) << "Successfully load model from " << hw_model;
    } catch (std::exception const &e) {
        LOG(ERROR) << "Error when load hw compiler onnx model: " << e.what();
        exit(0);
        exit(-1);
    }
    string strName;
@@ -292,7 +292,7 @@
    ifstream cmvn_stream(filename);
    if (!cmvn_stream.is_open()) {
        LOG(ERROR) << "Failed to open file: " << filename;
        exit(0);
        exit(-1);
    }
    string line;
@@ -475,7 +475,9 @@
    if (char_list.back() == "</s>") {
        char_list.pop_back();
    }
    if (char_list.empty()) {
        return ;
    }
    vector<vector<float>> timestamp_list;
    vector<string> new_char_list;
    vector<float> fire_place;
@@ -490,6 +492,9 @@
    if(num_peak != (int)char_list.size() + 1){
        float sum = std::accumulate(us_alphas.begin(), us_alphas.end(), 0.0f);
        float scale = sum/((int)char_list.size() + 1);
        if(scale == 0){
            return;
        }
        cif_peak.clear();
        sum = 0.0;
        for(auto &alpha:us_alphas){
@@ -507,6 +512,11 @@
                fire_place.push_back(i + total_offset);
            }
        }
    }
    num_peak = fire_place.size();
    if(fire_place.size() == 0){
        return;
    }
    // begin silence
@@ -530,6 +540,10 @@
    }
    // tail token and end silence
    if(timestamp_list.size()==0){
        LOG(ERROR)<<"timestamp_list's size is 0!";
        return;
    }
    if (num_frames - fire_place.back() > START_END_THRESHOLD) {
        float _end = (num_frames + fire_place.back()) / 2.0;
        timestamp_list.back()[1] = _end * TIME_RATE;