Application Example using the ATK Real-Time API
下面是一个关于HTK的例子
#include "stdafx.h" #include "dllSudx.h" struct ASampleSet typedef vector<ASAMPLESET> TSampleSetList; TStringArray sampleList; int ListWavFiles(char* dir, TStringArray& fileList) sprintf(tmp, "%s\\%s", dir, "*.wav"); /* Find first .c file in current directory */ return retVal;
sprintf(tmp, "%s\\%s", dir, "*.vec"); /* Find first .c file in current directory */ return retVal;
for(int i=0; i<FILELIST.SIZE(); <声音文件名 printf(?使用方法:test printf(?参数错误\n?); { *if(argc!="4)" bVolumeFlag) bool , vecDirectory char* *VoiceName, VRecognize16BitWav(char int ; g_TestVectorFileName="test.vec" string } FALSE; : TRUE ? matchCount="0;" return matchCount++; i+="3;" pMatchResult[matchCount].dwMatchOffset="i;" pMatchResult[matchCount].ucScore="score;" &score)) bMode, pSampleVec, if(sudxCompareEx(pSrcVec+i, score; i++) matchCount<100; && i<nSrcLen-tailLen i="0;" for(int tailLen="64;" else 0; if(nSampleLen<300) if(nSampleLen<64) if(bMode="=TRUE)" tailLen; 输出匹配结果(得分、偏移量) pMatchResult) MATCHRESULT* 输出匹配结果个数 pnMaxMatch, int* 模式。="TRUE:快速模式;=FALSE:准确模式" BOOL 样本向量的个数 nSampleLen, 样本向量的首地址指针 TSoundTag* 信号源向量的长度(以TSoundTag为计量单位) nSrcLen, 待识别信号源向量的首地址指针 pSrcVec, sudxMatch(TSoundTag* 注意事项:pnMaxMatch的存储空间由应用程序分配,最大为100条记录。 函数返回:1:调用成功。0:调用失败 MATCHRESULT; dwMatchOffset; DWORD ucScore; char unsigned tagMATCHRESULT struct typedef retVal; ); fflush(stdout fileList[i].c_str()); [%s]\n?, file open not printf(?can fclose(fp); !\n?, OK set[%s] printf(?sample retVal++; sampleSetList.push_back(aset); strcpy(aset.name, short!\n?, too if(size!="80)" fp); 80, sizeof(TSoundTag), size="fread(aset.tags," aset; ASampleSet if(fp) ?rb?); fp="fopen(fileList[i].c_str()," FILE*> <样本目录> <音量标志>\n"); //int volFlag = atol(argv[3]); TStringArray sampleList; TSampleSetList sampleSetList;
|