首页 > Web开发 > 详细

第44月第14天 webrtc vad检测

时间:2020-05-14 12:44:29      阅读:70      评论:0      收藏:0      [点我收藏+]

1.

void TestVAD(char* pAudioFile,char* pResFile,int nSample,int nMode)
{
    VadInst* pVad = NULL;
    if (WebRtcVad_Create(&pVad))
    {
        perror("WebRtcVad_Create failed!");
        return;
    }
 
    if (WebRtcVad_Init(pVad))
    {
        perror("WebRtcVad_Init failed!");
        return;
    }
 
    if (WebRtcVad_set_mode(pVad, nMode))
    {
        perror("WebRtcVad_set_mode failed!");
        return;
    }
 
    FILE* fp = NULL;
    FILE* fpR = NULL;
    fp = fopen(pAudioFile, "rb");
    fpR = fopen(pResFile, "wb");
    fseek(fp, 0, SEEK_END);
    unsigned int nLen = ftell(fp);
    fseek(fp, 0, SEEK_SET);
    short shBufferIn[160] = { 0 };
    while (1)
    {
        if (160 != fread(shBufferIn, 2, 160, fp))
            break;
        int nRet = WebRtcVad_Process(pVad, 16000, shBufferIn, 160);
        printf("%d", nRet);
        if (1 == nRet)
        {
            fwrite(shBufferIn, 2, 160, fpR);
        }
    }
 
    fclose(fpR);
    fclose(fp);
    WebRtcVad_Free(pVad);
}

https://blog.csdn.net/qq_30948113/article/details/68928549

 

第44月第14天 webrtc vad检测

原文:https://www.cnblogs.com/javastart/p/12887387.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!