Remove VAD.

This commit is contained in:
mayong 2023-03-16 11:44:13 +08:00
parent 6f18b5619a
commit f127377541
3 changed files with 63 additions and 16 deletions

View File

@ -237,7 +237,7 @@ bool Audio::loadpcmwav(const char* buf, int nBufLen)
size_t nOffset = 0;
#define WAV_HEADER_SIZE 44
speech_len = nBufLen / 2;
speech_align_len = (int)(ceil((float)speech_len / align_size) * align_size);
@ -263,7 +263,8 @@ bool Audio::loadpcmwav(const char* buf, int nBufLen)
speech_data[i] = (float)speech_buff[i] / scale;
}
AudioFrame* frame = new AudioFrame(speech_len);
frame_queue.push(frame);
return true;
}

View File

@ -26,8 +26,9 @@ extern "C" {
return nullptr;
Audio audio(1);
audio.loadwav(szBuf,nLen);
audio.split();
if (!audio.loadwav(szBuf, nLen))
return nullptr;
//audio.split();
float* buff;
int len;
@ -58,8 +59,9 @@ extern "C" {
return nullptr;
Audio audio(1);
audio.loadpcmwav(szBuf, nLen);
audio.split();
if (!audio.loadpcmwav(szBuf, nLen))
return nullptr;
//audio.split();
float* buff;
int len;
@ -91,8 +93,9 @@ extern "C" {
return nullptr;
Audio audio(1);
audio.loadpcmwav(szFileName);
audio.split();
if (!audio.loadpcmwav(szFileName))
return nullptr;
//audio.split();
float* buff;
int len;
@ -125,7 +128,7 @@ extern "C" {
Audio audio(1);
if(!audio.loadwav(szWavfile))
return nullptr;
audio.split();
//audio.split();
float* buff;
int len;

View File

@ -8,7 +8,7 @@
#include "librapidasrapi.h"
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[])
@ -40,10 +40,13 @@ int main(int argc, char *argv[])
gettimeofday(&start, NULL);
RPASR_RESULT Result=RapidAsrRecogPCMFile(AsrHanlde, argv[2], RASR_NONE, NULL);
gettimeofday(&end, NULL);
float snippet_time = 0.0f;
RPASR_RESULT Result=RapidAsrRecogFile(AsrHanlde, argv[2], RASR_NONE, NULL);
gettimeofday(&end, NULL);
if (Result)
{
string msg = RapidAsrGetResult(Result, 0);
@ -56,11 +59,51 @@ int main(int argc, char *argv[])
}
else
{
cout <<("no return data!");
cout <<"no return data!";
}
printf("Audio length %lfs.\n", (double)snippet_time);
//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);
long taking_micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec);
printf("Model inference takes %lfs.\n", (double)taking_micros / 1000000);