| | |
| | | #include <win_func.h> |
| | | #endif |
| | | |
| | | #include "librapidasrapi.h" |
| | | #include "libfunasrapi.h" |
| | | |
| | | #include <iostream> |
| | | #include <fstream> |
| | |
| | | // is quantize |
| | | bool quantize = false; |
| | | istringstream(argv[3]) >> boolalpha >> quantize; |
| | | RPASR_HANDLE AsrHanlde=RapidAsrInit(argv[1], nThreadNum, quantize); |
| | | FUNASR_HANDLE AsrHanlde=FunASRInit(argv[1], nThreadNum, quantize); |
| | | |
| | | if (!AsrHanlde) |
| | | { |
| | |
| | | gettimeofday(&start, NULL); |
| | | float snippet_time = 0.0f; |
| | | |
| | | RPASR_RESULT Result=RapidAsrRecogFile(AsrHanlde, argv[2], RASR_NONE, NULL); |
| | | FUNASR_RESULT Result=FunASRRecogFile(AsrHanlde, argv[2], RASR_NONE, NULL); |
| | | |
| | | gettimeofday(&end, NULL); |
| | | |
| | | if (Result) |
| | | { |
| | | string msg = RapidAsrGetResult(Result, 0); |
| | | string msg = FunASRGetResult(Result, 0); |
| | | setbuf(stdout, NULL); |
| | | cout << "Result: \""; |
| | | cout << msg << "\"." << endl; |
| | | snippet_time = RapidAsrGetRetSnippetTime(Result); |
| | | RapidAsrFreeResult(Result); |
| | | printf("Result: %s \n", msg.c_str()); |
| | | snippet_time = FunASRGetRetSnippetTime(Result); |
| | | FunASRFreeResult(Result); |
| | | } |
| | | else |
| | | { |
| | | cout <<"no return data!"; |
| | | } |
| | | |
| | | //char* buff = nullptr; |
| | | //int len = 0; |
| | | //ifstream ifs(argv[2], std::ios::binary | std::ios::in); |
| | | //if (ifs.is_open()) |
| | | //{ |
| | | // ifs.seekg(0, std::ios::end); |
| | | // len = ifs.tellg(); |
| | | // ifs.seekg(0, std::ios::beg); |
| | | |
| | | // buff = new char[len]; |
| | | |
| | | // ifs.read(buff, len); |
| | | |
| | | |
| | | // //RPASR_RESULT Result = RapidAsrRecogPCMFile(AsrHanlde, argv[2], RASR_NONE, NULL); |
| | | |
| | | // RPASR_RESULT Result=RapidAsrRecogPCMBuffer(AsrHanlde, buff,len, RASR_NONE, NULL); |
| | | // //RPASR_RESULT Result = RapidAsrRecogPCMFile(AsrHanlde, argv[2], RASR_NONE, NULL); |
| | | // gettimeofday(&end, NULL); |
| | | // |
| | | // if (Result) |
| | | // { |
| | | // string msg = RapidAsrGetResult(Result, 0); |
| | | // setbuf(stdout, NULL); |
| | | // cout << "Result: \""; |
| | | // cout << msg << endl; |
| | | // cout << "\"." << endl; |
| | | // snippet_time = RapidAsrGetRetSnippetTime(Result); |
| | | // RapidAsrFreeResult(Result); |
| | | // } |
| | | // else |
| | | // { |
| | | // cout <<"no return data!"; |
| | | // } |
| | | |
| | | // |
| | | //delete[]buff; |
| | | //} |
| | | |
| | | printf("Audio length %lfs.\n", (double)snippet_time); |
| | | seconds = (end.tv_sec - start.tv_sec); |
| | |
| | | printf("Model inference takes %lfs.\n", (double)taking_micros / 1000000); |
| | | printf("Model inference RTF: %04lf.\n", (double)taking_micros/ (snippet_time*1000000)); |
| | | |
| | | RapidAsrUninit(AsrHanlde); |
| | | FunASRUninit(AsrHanlde); |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | |