資源簡介
提取的webrtc VAD模塊 可運行
代碼片段和文件信息
//?audioprocess.cpp?:?定義控制臺應用程序的入口點。
//
#include?“stdafx.h“
#include?
#include?“webrtc_vad.h“
#define??frameLENGTH?80
#define?SAMPLE_RATE?8000
void?vadTest(){
FILE?*fpInputf?*fpOutput;
fpInputf?=?fopen(“F01S00_8k.raw“?“rb“);
if?(fpInputf?==?NULL){
return;
}
fpOutput?=?fopen(“F01S00_8k2.raw“?“wb“);
VadInst*inst?=?WebRtcVad_Create();
WebRtcVad_Init(inst);
WebRtcVad_set_mode(inst?2);
short?audioframe[frameLENGTH];
short?audioframe2[frameLENGTH];
while?(!feof(fpInputf))
{
int?read_size?=?fread(audioframe?sizeof(short)?frameLENGTH?fpInputf);
int?status?=?WebRtcVad_Process(inst?SAMPLE_RATE?audioframe?frameLENGTH);
if?(status?==?-1)
{
printf(“WebRtcVad_Process?is?error\n“);
return;
}
printf(“%d“?status);
if?(status?==?1){
fwrite(audioframe?sizeof(short)?read_size?fpOutput);
fflush(fpOutput);
}
}
fclose(fpOutput);
fclose(fpInputf);
WebRtcVad_Free(inst);
}
int?_tmain(int?argc?_TCHAR*?argv[])
{
vadTest();
return?0;
}
評論
共有 條評論