From 602fe75a1f0a8d64ccb6fc4d69ad510872fdfd13 Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期五, 17 三月 2023 20:30:40 +0800
Subject: [PATCH] rtf benchmark
---
funasr/runtime/onnxruntime/src/librapidasrapi.cpp | 41 +++++++++++++++++++++++++----------------
1 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/funasr/runtime/onnxruntime/src/librapidasrapi.cpp b/funasr/runtime/onnxruntime/src/librapidasrapi.cpp
index 4e1a457..f5f9d66 100644
--- a/funasr/runtime/onnxruntime/src/librapidasrapi.cpp
+++ b/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;
--
Gitblit v1.9.1