From bf6947bcb2e135d2fab5dc4a66654ebcfef24b85 Mon Sep 17 00:00:00 2001
From: zhaomingwork <61895407+zhaomingwork@users.noreply.github.com>
Date: 星期二, 29 八月 2023 10:45:34 +0800
Subject: [PATCH] for h5 root url redirect to index (#898)

---
 funasr/runtime/onnxruntime/src/paraformer.cpp |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/funasr/runtime/onnxruntime/src/paraformer.cpp b/funasr/runtime/onnxruntime/src/paraformer.cpp
index 9b92e90..c36a86d 100644
--- a/funasr/runtime/onnxruntime/src/paraformer.cpp
+++ b/funasr/runtime/onnxruntime/src/paraformer.cpp
@@ -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;
@@ -658,7 +672,7 @@
         return "";
     }
 
-    string result;
+    string result="";
     try {
         auto outputTensor = m_session_->Run(Ort::RunOptions{nullptr}, m_szInputNames.data(), input_onnx.data(), input_onnx.size(), m_szOutputNames.data(), m_szOutputNames.size());
         std::vector<int64_t> outputShape = outputTensor[0].GetTensorTypeAndShapeInfo().GetShape();

--
Gitblit v1.9.1