Commit 959796fb authored by mayong's avatar mayong
Browse files

BUGFIX: RTF.

parent c357b7e2
...@@ -51,6 +51,7 @@ class Audio { ...@@ -51,6 +51,7 @@ class Audio {
int fetch(float *&dout, int &len, int &flag); int fetch(float *&dout, int &len, int &flag);
void padding(); void padding();
void split(); void split();
float get_time_len();
int get_queue_size() { return (int)frame_queue.size(); } int get_queue_size() { return (int)frame_queue.size(); }
}; };
......
...@@ -116,6 +116,12 @@ void Audio::disp() ...@@ -116,6 +116,12 @@ void Audio::disp()
speech_len); speech_len);
} }
float Audio::get_time_len()
{
return (float)speech_len / 16000;
//speech_len);
}
bool Audio::loadwav(const char *filename) bool Audio::loadwav(const char *filename)
{ {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
typedef struct typedef struct
{ {
std::string msg; std::string msg;
float snippet_time;
}RPASR_RECOG_RESULT; }RPASR_RECOG_RESULT;
......
...@@ -34,21 +34,24 @@ int main(int argc, char *argv[]) ...@@ -34,21 +34,24 @@ int main(int argc, char *argv[])
gettimeofday(&end, NULL); gettimeofday(&end, NULL);
long seconds = (end.tv_sec - start.tv_sec); long seconds = (end.tv_sec - start.tv_sec);
long micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec); long modle_init_micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec);
printf("Model initialization takes %lfs.\n", (double)micros / 1000000); printf("Model initialization takes %lfs.\n", (double)modle_init_micros / 1000000);
setbuf(stdout, NULL);
cout << "Result: \"";
gettimeofday(&start, NULL); gettimeofday(&start, NULL);
RPASR_RESULT Result=RapidAsrRecogPCMFile(AsrHanlde, argv[2], RASR_NONE, NULL); RPASR_RESULT Result=RapidAsrRecogPCMFile(AsrHanlde, argv[2], RASR_NONE, NULL);
gettimeofday(&end, NULL); gettimeofday(&end, NULL);
float snippet_time = 0.0f;
if (Result) if (Result)
{ {
string msg = RapidAsrGetResult(Result, 0); string msg = RapidAsrGetResult(Result, 0);
setbuf(stdout, NULL);
cout << "Result: \"";
cout << msg << endl; cout << msg << endl;
cout << "\"." << endl; cout << "\"." << endl;
snippet_time = RapidAsrGetRetSnippetTime(Result);
RapidAsrFreeResult(Result); RapidAsrFreeResult(Result);
} }
else else
...@@ -58,9 +61,9 @@ int main(int argc, char *argv[]) ...@@ -58,9 +61,9 @@ int main(int argc, char *argv[])
seconds = (end.tv_sec - start.tv_sec); seconds = (end.tv_sec - start.tv_sec);
long taking_micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec); long taking_micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec);
printf("Model inference takes %lfs.\n", (double)micros / 1000000); printf("Model inference takes %lfs.\n", (double)taking_micros / 1000000);
printf("Model inference RTF: %04lf.\n", (double)taking_micros/micros ); printf("Model inference RTF: %04lf.\n", (double)taking_micros/ (snippet_time*1000000));
RapidAsrUninit(AsrHanlde); RapidAsrUninit(AsrHanlde);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment