zhifu gao
2023-03-16 d1cde93914d368b807c538b3b1b0270984fb6126
funasr/runtime/onnxruntime/src/librapidasrapi.cpp
@@ -1,9 +1,6 @@
#include "precomp.h"
#ifdef __cplusplus 
//  void __attribute__ ((visibility ("default"))) fun();
extern "C" {
#endif
@@ -12,12 +9,6 @@
   _RAPIDASRAPI RPASR_HANDLE  RapidAsrInit(const char* szModelDir, int nThreadNum)
   {
#ifdef NDEBUG
      QMLIC_BOOL bMatched = QmLicCheckValid(QLFM_ASR);
      if (!bMatched) {
         return nullptr;
      }
#endif
      Model* mm = create_model(szModelDir, nThreadNum); 
@@ -35,13 +26,15 @@
         return nullptr;
      Audio audio(1);
      audio.loadwav(szBuf,nLen);
      audio.split();
      if (!audio.loadwav(szBuf, nLen))
         return nullptr;
      //audio.split();
      float* buff;
      int len;
      int flag=0;
      RPASR_RECOG_RESULT* pResult = new RPASR_RECOG_RESULT;
      pResult->snippet_time = audio.get_time_len();
      int nStep = 0;
      int nTotal = audio.get_queue_size();
      while (audio.fetch(buff, len, flag) > 0) {
@@ -66,13 +59,15 @@
         return nullptr;
      Audio audio(1);
      audio.loadpcmwav(szBuf, nLen);
      audio.split();
      if (!audio.loadpcmwav(szBuf, nLen))
         return nullptr;
      //audio.split();
      float* buff;
      int len;
      int flag = 0;
      RPASR_RECOG_RESULT* pResult = new RPASR_RECOG_RESULT;
      pResult->snippet_time = audio.get_time_len();
      int nStep = 0;
      int nTotal = audio.get_queue_size();
      while (audio.fetch(buff, len, flag) > 0) {
@@ -98,13 +93,15 @@
         return nullptr;
      Audio audio(1);
      audio.loadpcmwav(szFileName);
      audio.split();
      if (!audio.loadpcmwav(szFileName))
         return nullptr;
      //audio.split();
      float* buff;
      int len;
      int flag = 0;
      RPASR_RECOG_RESULT* pResult = new RPASR_RECOG_RESULT;
      pResult->snippet_time = audio.get_time_len();
      int nStep = 0;
      int nTotal = audio.get_queue_size();
      while (audio.fetch(buff, len, flag) > 0) {
@@ -131,7 +128,7 @@
      Audio audio(1);
      if(!audio.loadwav(szWavfile))
         return nullptr;
      audio.split();
      //audio.split();
      float* buff;
      int len;
@@ -139,6 +136,7 @@
      int nStep = 0;
      int nTotal = audio.get_queue_size();
      RPASR_RECOG_RESULT* pResult = new RPASR_RECOG_RESULT;
      pResult->snippet_time = audio.get_time_len();
      while (audio.fetch(buff, len, flag) > 0) {
         pRecogObj->reset();
         string msg = pRecogObj->forward(buff, len, flag);
@@ -162,6 +160,17 @@
      return 1;
      
   }
   _RAPIDASRAPI const float RapidAsrGetRetSnippetTime(RPASR_RESULT Result)
   {
      if (!Result)
         return 0.0f;
      return ((RPASR_RECOG_RESULT*)Result)->snippet_time;
   }
   _RAPIDASRAPI const char* RapidAsrGetResult(RPASR_RESULT Result,int nIndex)
   {
      RPASR_RECOG_RESULT * pResult = (RPASR_RECOG_RESULT*)Result;