一、音訊降噪
void testns(char *szfilein, int nsample, int nmode)
if (0 != webrtcns_init(pns_inst, nsample))
if (0 != webrtcns_set_policy(pns_inst, nmode))
fpin = fopen(szfilein, "rb");
if (null == fpin)
fseek(fpin, 0, seek_end);
nfilesize = ftell(fpin);
fseek(fpin, 0, seek_set);
pinbuffer = (char*)malloc(nfilesize);
memset(pinbuffer, 0, nfilesize);
fread(pinbuffer, sizeof(char), nfilesize, fpin);
poutbuffer = (char*)malloc(nfilesize);
memset(poutbuffer, 0, nfilesize);
ntime = gettickcount();
for (i = 0; i < nfilesize; i += 320)
; short shbufferout[160] = ;
float fbufferin[160] = ;
float fbufferout[160] = ;
memcpy(shbufferin, (char*)(pinbuffer + i), 160 * sizeof(short));
for (int k = 0; k < 160; ++k)
if (0 == webrtcns_process(pns_inst, fbufferin, null, fbufferout, null))
memcpy(poutbuffer + i, shbufferout, 160 * sizeof(short));}}
} ntime = gettickcount() - ntime;
printf("n_s user time=%dms\n", ntime);
char szfileout[20] = "ns_file";
char* pline = strchr(szfilein, '\\');
strcat(szfileout, pline);
fpout = fopen(szfileout, "wb");
if (null == fpout)
fwrite(poutbuffer, sizeof(char), nfilesize, fpout);
} while (0);
webrtcns_free(pns_inst);
fclose(fpin);
fclose(fpout);
free(pinbuffer);
free(poutbuffer);
}
需要注意的是,如果傳入的音訊取樣率大於32000,要將音訊分為高低音訊傳入。
二、vad檢測
void testvad(char* paudiofile,char* presfile,int nsample,int nmode)
if (webrtcvad_init(pvad))
if (webrtcvad_set_mode(pvad, nmode))
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] = ;
while (1) }
fclose(fpr);
fclose(fp);
webrtcvad_free(pvad);
}
vad檢測有4種模式,0,1,2,3可以自己體驗一下。
使用i18n對vue專案進行國際化
一 安裝元件 npm install vue i18n二 在src lang資料夾下新建cn.js和en.js 1 cn.js export const m 2 en.js export const m 三 在src i18n資料夾下新建index.js檔案。沒有直接將這部分寫入main.js中是因...
填格仔3 N的方框使用2 1的矩形進行填充
考慮每個位置的前乙個狀態 可以發現有 我們分別給他們編號 假設 現在填充到了i 1行,我們可以發現從i行可以通過填充轉到i 1行的狀態 第i行第j列表示 可以 從上乙個轉態 j 可以到達這個狀態的j 然後又了這個轉態轉化在使用矩陣 為初始狀態 include include include incl...
產生N個隨機數,使用選擇排序,對隨機數進行排序
include include include define n 100 資料個數 define u 1000 資料個數 int data n 存放資料的陣列 int comp count 0 資料比較次數 int swap count 0 資料交換次數 新增隨機數到陣列 void add data...