From 39529df088e74988257dd4dac9adc818080cb49f Mon Sep 17 00:00:00 2001
From: mayong <mayong@qianxin.com>
Date: 星期二, 07 三月 2023 12:15:07 +0800
Subject: [PATCH] update files.
---
funasr/runtime/onnxruntime/tester/tester.cpp | 50 ++++++++++++++++++++++++--------------------------
1 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/funasr/runtime/onnxruntime/tester/tester.cpp b/funasr/runtime/onnxruntime/tester/tester.cpp
index 7bfb4c0..21b783f 100644
--- a/funasr/runtime/onnxruntime/tester/tester.cpp
+++ b/funasr/runtime/onnxruntime/tester/tester.cpp
@@ -1,12 +1,13 @@
-#include <iostream>
+
#ifndef _WIN32
#include <sys/time.h>
#else
#include <win_func.h>
#endif
-#include <Audio.h>
-#include <Model.h>
+#include "librapidasrapi.h"
+
+#include <iostream>
using namespace std;
@@ -21,52 +22,49 @@
struct timeval start, end;
gettimeofday(&start, NULL);
int nThreadNum = 4;
- Model* mm = create_model(argv[1], nThreadNum);
- if (!mm)
+ RPASR_HANDLE AsrHanlde=RapidAsrInit(argv[1], nThreadNum);
+
+ if (!AsrHanlde)
{
printf("Cannot load ASR Model from: %s, there must be files model.onnx and vocab.txt", argv[1]);
exit(-1);
}
-
- Audio audio(0);
- if (!audio.loadwav(argv[2]))
- {
- printf("cannot load %s\n", argv[2]);
- return -1;
- }
- audio.disp();
-
+
gettimeofday(&end, NULL);
long seconds = (end.tv_sec - start.tv_sec);
long micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec);
printf("Model initialization takes %lfs.\n", (double)micros / 1000000);
- audio.split();
setbuf(stdout, NULL);
cout << "Result: \"";
gettimeofday(&start, NULL);
- float *buff;
- int len;
- int flag;
- while (audio.fetch(buff, len, flag) > 0) {
- mm->reset();
- string msg = mm->forward(buff, len, flag);
- cout << msg;
- }
+ RPASR_RESULT Result=RapidAsrRecogPCMFile(AsrHanlde, argv[2], RASR_NONE, NULL);
gettimeofday(&end, NULL);
- cout << "\"." << endl;
-
+ if (Result)
+ {
+ string msg = RapidAsrGetResult(Result, 0);
+ cout << msg << endl;
+ cout << "\"." << endl;
+ RapidAsrFreeResult(Result);
+ }
+ else
+ {
+ cout <<("no return data!");
+ }
+
seconds = (end.tv_sec - start.tv_sec);
long taking_micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec);
printf("Model inference takes %lfs.\n", (double)micros / 1000000);
printf("Model inference RTF: %04lf.\n", (double)taking_micros/micros );
- delete mm;
+ RapidAsrUninit(AsrHanlde);
return 0;
}
+
+
\ No newline at end of file
--
Gitblit v1.9.1