DHMM_VQ_MFC.cpp
资源名称:VQ-DHMM.rar [点击查看]
上传用户:avbj512
上传日期:2013-09-18
资源大小:6239k
文件大小:17k
源码类别:
DSP编程
开发平台:
Visual C++
- // DHMM_VQ_MFC.cpp:
- // Implementation of the DHMM_VQ_MFC Module.
- // That is to Train VQ Code_Book.
- //
- // Created 2001/08, By DongMing, MDSR.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "DHMM_VQ_MFC.h"
- #include "kwspot.h"
- #include "DAT_File_Access.h"
- #include "DHMM_GL.h"
- #include "DHMM_LHS.h"
- #include "DHMM_HQ.h"
- #include "DHMM_WP.h"
- //////////////////////////////////////////////////////////////////////
- // Private functions
- // 函数功能:将一个词的一帧特征进行VQ编码
- int DHMM_VQ_Encode_A_Code_Word(DYNA_2DIM_DOUBLE_ARRAY d2dda_Code_Book, int n_Code_Book_Size, int n_Code_Word_Dim,
- double * pd_Code_Word);
- // 函数功能:将一个词的一帧特征进行VQ编码,定点程序
- int DHMM_VQ_Encode_A_Code_Word_FIX(DYNA_2DIM_INT_ARRAY d2dna_Code_Book, int n_Code_Book_Size, int n_Code_Word_Dim,
- int * pn_Code_Word);
- extern PRO_CONFIG u_Pro_Config;
- //////////////////////////////////////////////////////////////////////
- // API functions
- //////////////////////////////////////////////////////////////////////
- // 函数名称:DHMM_VQ
- // 函数功能:DHMM程序进行码书训练模块的入口
- // 函数性质:API
- // 输入参数:
- // 无
- // 输出参数:
- // 无
- // 返回值:
- // 0 表示成功
- // 备注:本模块完成DHMM的码书训练,模块的应用接口实际上是基于文件的,
- // 训练的码书存放在u_Pro_Config.sz_Tmp_Code_Book_File_Name
- int DHMM_VQ(void)
- {
- int nRetCode;
- DYNA_2DIM_DOUBLE_ARRAY d2dda_Code_Book;
- DYNA_2DIM_DOUBLE_ARRAY d2dda_Total_Feature;
- long n_Total_Feature_Num;
- d2dda_Code_Book = d2dda_New(u_Pro_Config.n_VQ_Code_Book_Size, u_Pro_Config.n_Feature_Dim);
- ASSERT(d2dda_Code_Book != NULL);
- // Load_Only Code_Book
- if ((u_Pro_Config.l_VQ_Config & VQ_CONFIG_GENERATE_CODE_BOOK_MASK) == VQ_CONFIG_LOAD_ONLY_CODE_BOOK)
- {
- nRetCode = DHMM_VQ_Load_Code_Book_File(u_Pro_Config.sz_Toload_Code_Book_File_Name,
- d2dda_Code_Book, u_Pro_Config.n_VQ_Code_Book_Size, u_Pro_Config.n_Feature_Dim);
- ASSERT(nRetCode == 0);
- }
- // Train_Only Code_Book
- else if ((u_Pro_Config.l_VQ_Config & VQ_CONFIG_GENERATE_CODE_BOOK_MASK) == VQ_CONFIG_TRAIN_ONLY_CODE_BOOK)
- {
- nRetCode = DHMM_VQ_Load_All_Feature(&d2dda_Total_Feature, &n_Total_Feature_Num);
- ASSERT(nRetCode == 0);
- nRetCode = DHMM_VQ_Train_Code_Book(d2dda_Total_Feature, n_Total_Feature_Num, u_Pro_Config.n_Feature_Dim,
- NULL, d2dda_Code_Book, u_Pro_Config.n_VQ_Code_Book_Size);
- ASSERT(nRetCode == 0);
- nRetCode = DHMM_VQ_Save_Code_Book_File(u_Pro_Config.sz_Toload_Code_Book_File_Name,
- d2dda_Code_Book, u_Pro_Config.n_VQ_Code_Book_Size, u_Pro_Config.n_Feature_Dim);
- ASSERT(nRetCode == 0);
- DHMM_VQ_To_519_CodeBook();
- d2dda_Free(d2dda_Total_Feature, n_Total_Feature_Num, u_Pro_Config.n_Feature_Dim);
- }
- nRetCode = DHMM_VQ_Save_Code_Book_File(u_Pro_Config.sz_Toload_Code_Book_File_Name,
- d2dda_Code_Book, u_Pro_Config.n_VQ_Code_Book_Size, u_Pro_Config.n_Feature_Dim);
- ASSERT(nRetCode == 0);
- d2dda_Free(d2dda_Code_Book, u_Pro_Config.n_VQ_Code_Book_Size, u_Pro_Config.n_Feature_Dim);
- return 0;
- }
- //////////////////////////////////////////////////////////////////////
- // 函数名称:DHMM_VQ_Train_Code_Book
- // 函数功能:训练码书
- // 函数性质:API
- // 输入参数:
- // d2dda_Total_Feature,存放所有的特征
- // n_Total_Feature_Num,总的特征数
- // n_Code_Word_Dim,特征维数
- // d2dda_Initial_Code_Book,存放初始码书,允许为NULL,表示程序自动初始化
- // n_Code_Book_Size,码书大小
- // 输出参数:
- // d2dda_Code_Book,存放训好的码书
- // 返回值:
- // 0 表示成功
- // 备注:
- // 该函数是一个分发函数,按照u_Pro_Config.l_VQ_Config配置的信息
- // 将具体调用不同的函数体
- int DHMM_VQ_Train_Code_Book(DYNA_2DIM_DOUBLE_ARRAY d2dda_Total_Feature, int n_Total_Feature_Num, int n_Code_Word_Dim,
- DYNA_2DIM_DOUBLE_ARRAY d2dda_Initial_Code_Book, DYNA_2DIM_DOUBLE_ARRAY d2dda_Code_Book, int n_Code_Book_Size)
- {
- switch (u_Pro_Config.l_VQ_Config & VQ_CONFIG_TRAIN_PROCEDURE_MASK)
- {
- case VQ_CONFIG_TRAIN_PROCEDURE_STD:
- ASSERT(0);
- break;
- case VQ_CONFIG_TRAIN_PROCEDURE_GL:
- return DHMM_VQ_Train_Code_Book_GL(d2dda_Total_Feature, n_Total_Feature_Num, n_Code_Word_Dim,
- d2dda_Initial_Code_Book, d2dda_Code_Book, n_Code_Book_Size);
- break;
- case VQ_CONFIG_TRAIN_PROCEDURE_LHS:
- ASSERT(0); //LHS的训练过程,与GL的完全相同,故略去
- break;
- case VQ_CONFIG_TRAIN_PROCEDURE_HQ:
- return DHMM_VQ_Train_Code_Book_HQ(d2dda_Total_Feature, n_Total_Feature_Num, n_Code_Word_Dim,
- d2dda_Initial_Code_Book, d2dda_Code_Book, n_Code_Book_Size);
- break;
- case VQ_CONFIG_TRAIN_PROCEDURE_WP:
- return DHMM_VQ_Train_Code_Book_WP(d2dda_Total_Feature, n_Total_Feature_Num, n_Code_Word_Dim,
- d2dda_Initial_Code_Book, d2dda_Code_Book, n_Code_Book_Size);
- break;
- default:
- ASSERT(0);
- break;
- }
- return 0;
- }
- //////////////////////////////////////////////////////////////////////
- // 函数名称:DHMM_VQ_Save_Code_Book_File
- // 函数功能:向.DAT格式的码书文件中存储码书
- // 函数性质:API
- // 输入参数:
- // sz_Tosave_Code_Book_File_Name,存放码书的文件名
- // n_Code_Book_Size,码书的大小(VQ的结果数)
- // n_Code_Word_Dim,每个码字的维数
- // 输出参数:
- // d2dda_Code_Book,存放待写入的码书
- // 返回值:
- // 0 表示成功
- // 备注:
- // 码书存储使用.DAT格式中的码书存储格式,可参见DAT_File_Access模块
- int DHMM_VQ_Save_Code_Book_File(char * sz_Tosave_Code_Book_File_Name,
- DYNA_2DIM_DOUBLE_ARRAY d2dda_Code_Book, int n_Code_Book_Size, int n_Code_Word_Dim)
- {
- FILE * fp_Code_Book_File;
- CODE_BOOK_FILE_HEAD u_Code_Book_File_Head;
- long l_Word_Sample_Offset;
- int n_Code_Word_Index;
- long lTmp;
- fp_Code_Book_File = fopen(sz_Tosave_Code_Book_File_Name, "wb");
- ASSERT(fp_Code_Book_File != NULL);
- memset(&u_Code_Book_File_Head, 0, sizeof(u_Code_Book_File_Head));
- u_Code_Book_File_Head.lVersion = DAT_FILE_VERSION;
- strcpy(u_Code_Book_File_Head.szName, "CodeBook");
- u_Code_Book_File_Head.sCodeBookNum = u_Code_Book_File_Head.sCodeBookNum2 = 1;
- strcpy(u_Code_Book_File_Head.szParameterType, "CodeBook");
- u_Code_Book_File_Head.sSampleType = SAMPLE_DATA_TYPE_DOUBLE;
- u_Code_Book_File_Head.sFeatureOrder = n_Code_Word_Dim;
- u_Code_Book_File_Head.sCodeBookSize = n_Code_Book_Size;
- ASSERT(sizeof(u_Code_Book_File_Head) == 200);
- fwrite(&u_Code_Book_File_Head, sizeof(u_Code_Book_File_Head), 1, fp_Code_Book_File);
- lTmp = 0;
- fwrite(&lTmp, sizeof(long), 1, fp_Code_Book_File);
- fwrite(&lTmp, sizeof(long), 1, fp_Code_Book_File);
- fseek(fp_Code_Book_File, 0, SEEK_END);
- l_Word_Sample_Offset = ftell(fp_Code_Book_File);
- fseek(fp_Code_Book_File, 200 + 4 * 2 * (0), SEEK_SET);
- fwrite(&l_Word_Sample_Offset, sizeof(long), 1, fp_Code_Book_File);
- fwrite(&n_Code_Book_Size, sizeof(long), 1, fp_Code_Book_File);
- fseek(fp_Code_Book_File, l_Word_Sample_Offset, SEEK_SET);
- for (n_Code_Word_Index = 0; n_Code_Word_Index < n_Code_Book_Size; n_Code_Word_Index++)
- {
- fwrite(d2dda_Code_Book[n_Code_Word_Index], sizeof(double), n_Code_Word_Dim, fp_Code_Book_File);
- }
- fclose(fp_Code_Book_File);
- return 0;
- }
- //////////////////////////////////////////////////////////////////////
- // 函数名称:DHMM_VQ_Load_Code_Book_File
- // 函数功能:从.DAT格式的码书文件中读取码书
- // 函数性质:API
- // 输入参数:
- // sz_Toload_Code_Book_File_Name,存放码书的文件名
- // n_Code_Book_Size,码书的大小(VQ的结果数)
- // n_Code_Word_Dim,每个码字的维数
- // 输出参数:
- // d2dda_Code_Book,存放读出的码书
- // 返回值:
- // 0 表示成功
- // 备注:
- // 码书存储使用.DAT格式中的码书存储格式,可参见DAT_File_Access模块
- int DHMM_VQ_Load_Code_Book_File(char * sz_Toload_Code_Book_File_Name,
- DYNA_2DIM_DOUBLE_ARRAY d2dda_Code_Book, int n_Code_Book_Size, int n_Code_Word_Dim)
- {
- FILE * fp_Code_Book_File;
- CODE_BOOK_FILE_HEAD u_Code_Book_File_Head;
- long l_Word_Sample_Offset;
- int n_Code_Word_Index;
- fp_Code_Book_File = fopen(sz_Toload_Code_Book_File_Name, "rb");
- ASSERT(fp_Code_Book_File != NULL);
- fread(&u_Code_Book_File_Head, sizeof(u_Code_Book_File_Head), 1, fp_Code_Book_File);
- ASSERT(u_Code_Book_File_Head.lVersion >= DAT_FILE_VERSION);
- ASSERT(u_Code_Book_File_Head.sCodeBookSize == n_Code_Book_Size);
- ASSERT(u_Code_Book_File_Head.sFeatureOrder == n_Code_Word_Dim);
- fread(&l_Word_Sample_Offset, sizeof(long), 1, fp_Code_Book_File);
- fseek(fp_Code_Book_File, l_Word_Sample_Offset, SEEK_SET);
- for (n_Code_Word_Index = 0; n_Code_Word_Index < n_Code_Book_Size; n_Code_Word_Index++)
- {
- fread(d2dda_Code_Book[n_Code_Word_Index], sizeof(double), n_Code_Word_Dim, fp_Code_Book_File);
- }
- fclose(fp_Code_Book_File);
- return 0;
- }
- //////////////////////////////////////////////////////////////////////
- // 函数名称:DHMM_VQ_Encode_A_Word_Sample
- // 函数功能:将一个词的所有帧特征进行VQ编码
- // 函数性质:API
- // 输入参数:
- // d2dda_Code_Book,存放码书
- // n_Code_Book_Size,码书大小
- // n_Code_Word_Dim,特征维数
- // pu_Word_Sample->d2dda_Feature_Sequence,待VQ的词每帧特征
- // 输出参数:
- // pu_Word_Sample->pn_VQed_Feature_Sequence,VQ后的词每帧特征
- // 返回值:
- // 0 表示成功
- // 备注:
- int DHMM_VQ_Encode_A_Word_Sample(DYNA_2DIM_DOUBLE_ARRAY d2dda_Code_Book, int n_Code_Book_Size, int n_Code_Word_Dim,
- WORD_SAMPLE * pu_Word_Sample)
- {
- int n_Word_Sample_Frame_Index;
- ASSERT(n_Code_Word_Dim == pu_Word_Sample->n_Feature_Dim);
- for (n_Word_Sample_Frame_Index = 0; n_Word_Sample_Frame_Index < pu_Word_Sample->n_Feature_Sequence_Len; n_Word_Sample_Frame_Index++)
- {
- pu_Word_Sample->pn_VQed_Feature_Sequence[n_Word_Sample_Frame_Index] =
- DHMM_VQ_Encode_A_Code_Word(d2dda_Code_Book, n_Code_Book_Size, n_Code_Word_Dim,
- pu_Word_Sample->d2dda_Feature_Sequence[n_Word_Sample_Frame_Index]);
- }
- return 0;
- }
- //////////////////////////////////////////////////////////////////////
- // 函数名称:DHMM_VQ_Encode_A_Code_Word
- // 函数功能:将一个词的一帧特征进行VQ编码
- // 函数性质:Private
- // 输入参数:
- // d2dda_Code_Book,存放码书
- // n_Code_Book_Size,码书大小
- // n_Code_Word_Dim,特征维数
- // pd_Code_Word,待VQ的一帧特征
- // 输出参数:
- // 无
- // 返回值:
- // VQ后的一帧特征
- // 备注:
- static int DHMM_VQ_Encode_A_Code_Word(DYNA_2DIM_DOUBLE_ARRAY d2dda_Code_Book, int n_Code_Book_Size, int n_Code_Word_Dim,
- double * pd_Code_Word)
- {
- int n_VQ_Result;
- double d_VQ_Result_Distance;
- int n_Code_Book_Word_Index, n_Code_Word_Dim_Index;
- double dTmp;
- double dSqr;
- n_VQ_Result = -1;
- d_VQ_Result_Distance = MAX_DOUBLE_VALUE;
- for (n_Code_Book_Word_Index = 0; n_Code_Book_Word_Index < n_Code_Book_Size; n_Code_Book_Word_Index++)
- {
- dTmp = 0.0F;
- for (n_Code_Word_Dim_Index = 0; n_Code_Word_Dim_Index < n_Code_Word_Dim; n_Code_Word_Dim_Index++)
- {
- dSqr = (pd_Code_Word[n_Code_Word_Dim_Index] - d2dda_Code_Book[n_Code_Book_Word_Index][n_Code_Word_Dim_Index])*32768/4;
- dTmp += dSqr * dSqr / 2;
- }
- if (dTmp < d_VQ_Result_Distance)
- {
- n_VQ_Result = n_Code_Book_Word_Index;
- d_VQ_Result_Distance = dTmp;
- }
- }
- return(n_VQ_Result);
- }
- int DHMM_VQ_To_519_CodeBook(void)
- {
- int nRetCode;
- DYNA_2DIM_DOUBLE_ARRAY d2dda_Code_Book;
- int n_Code_Word_Index;
- int n_Code_Book_Size = u_Pro_Config.n_VQ_Code_Book_Size;
- int n_Code_Word_Dim = u_Pro_Config.n_Feature_Dim;
- d2dda_Code_Book = d2dda_New(u_Pro_Config.n_VQ_Code_Book_Size, u_Pro_Config.n_Feature_Dim);
- ASSERT(d2dda_Code_Book != NULL);
- nRetCode = DHMM_VQ_Load_Code_Book_File(u_Pro_Config.sz_Toload_Code_Book_File_Name,
- d2dda_Code_Book, u_Pro_Config.n_VQ_Code_Book_Size, u_Pro_Config.n_Feature_Dim);
- ASSERT(nRetCode == 0);
- CString Code_Book_txt = u_Pro_Config.sz_Toload_Code_Book_File_Name;
- Code_Book_txt.Replace(".DAT","519.dat");
- FILE *fp_Code_Book_File = fopen(Code_Book_txt,"wb");
- // added by wangxia
- FILE *fp_Code_Book_TXT_File = fopen("..//..//data//codeTXT.dat","wb+");
- FILE *fp_Code_Book_BIN_File = fopen("..//..//data//codeBIN.dat","wb+");
- ASSERT(fp_Code_Book_File != NULL);
- short data;
- float f_data;
- for (n_Code_Word_Index = 0; n_Code_Word_Index < n_Code_Book_Size; n_Code_Word_Index++)
- {
- for(int dim = 0 ; dim < n_Code_Word_Dim; dim++)
- {
- f_data = ((d2dda_Code_Book[n_Code_Word_Index][dim]) * 32768L/4/* + 0.5F*/);
- ASSERT((f_data >= short(MIN_SHORT_VALUE)) && (f_data <= MAX_SHORT_VALUE));
- data = (short)f_data;
- fwrite(&data, sizeof(short), 1, fp_Code_Book_File);
- fprintf(fp_Code_Book_TXT_File, "%d,",data);
- fwrite(&data, sizeof(short), 1, fp_Code_Book_BIN_File);
- }
- }
- d2dda_Free(d2dda_Code_Book, u_Pro_Config.n_VQ_Code_Book_Size, u_Pro_Config.n_Feature_Dim);
- fclose(fp_Code_Book_File);
- fclose(fp_Code_Book_TXT_File);
- fclose(fp_Code_Book_BIN_File);
- return 0;
- }
- //////////////////////////////////////////////////////////////////////
- // 函数名称:DHMM_VQ_Load_All_Feature
- // 函数功能:从语料库中读取全部的特征
- // 函数性质:API
- // 输入参数:
- // 无
- // 输出参数:
- // pd2dda_Total_Feature,存放读出的特征
- // pn_Total_Feature_Num,存放读出的总的特征数
- // 返回值:
- // 0 表示成功
- // 备注:
- // !!!!!该函数的内存分配策略特别,
- // 返回的存储全部码字的数组,由callee分配内存,因此,caller必须负责释放!!!!!
- // 特征文件的文件名格式在u_Pro_Config.sz_Feature_Origin_File_Name_Format指出,
- // 语料库人数在u_Pro_Config.n_Feature_Person_Num指出
- int DHMM_VQ_Load_All_Feature(DYNA_2DIM_DOUBLE_ARRAY * pd2dda_Total_Feature, long * pn_Total_Feature_Num)
- {
- int nRetCode;
- char sz_Feature_File_Name[256];
- char sz_Silence_File_Name[256];
- FEATURE_FILE_HEAD u_Feature_File_Head;
- long n_Total_Frame_Num;
- DYNA_2DIM_DOUBLE_ARRAY d2dda_All_Feature;
- int n_Person_Index, n_Sentence_Index, n_Total_Frame_Index;
- // 统计所有语料库的总特征数目
- n_Total_Frame_Num = 0;
- for (n_Person_Index = 0; n_Person_Index < u_Pro_Config.n_Feature_Person_Num; n_Person_Index++)
- {
- // 如果只用训练集的特征训练VQ码本,则跳过统计测试集特征
- if ((u_Pro_Config.l_VQ_Config & VQ_CONFIG_LOAD_ALL_FEATURE_METHOD_MASK) == VQ_CONFIG_LOAD_TRAIN_SET_ONLY)
- {
- if (u_Pro_Config.n_DHMM_Model_Person_Start_Index <= u_Pro_Config.n_DHMM_Model_Person_End_Index)
- {
- if ((n_Person_Index < u_Pro_Config.n_DHMM_Model_Person_Start_Index) || (n_Person_Index > u_Pro_Config.n_DHMM_Model_Person_End_Index)) continue;
- }
- else
- {
- if ((n_Person_Index > u_Pro_Config.n_DHMM_Model_Person_End_Index) && (n_Person_Index < u_Pro_Config.n_DHMM_Model_Person_Start_Index)) continue;
- }
- }
- else if ((u_Pro_Config.l_VQ_Config & VQ_CONFIG_LOAD_ALL_FEATURE_METHOD_MASK) == VQ_CONFIG_LOAD_ALL_FEATURE)
- {}
- sprintf(sz_Feature_File_Name, u_Pro_Config.sz_Feature_Origin_File_Name_Format, n_Person_Index);
- nRetCode = dfa_Feature_Get_File_Info(sz_Feature_File_Name, &u_Feature_File_Head);
- ASSERT(nRetCode == 0);
- //ASSERT((u_Feature_File_Head.sSentenceNum == u_Feature_File_Head.sSentenceNum2) && (u_Feature_File_Head.sSentenceNum == u_Pro_Config.n_Feature_Sentence_Num)); ASSERT(u_Feature_File_Head.sFeatureOrder == u_Pro_Config.n_Feature_Dim);
- n_Total_Frame_Num += dfa_Feature_Get_File_Total_Frame_Num(sz_Feature_File_Name, u_Pro_Config.n_Feature_Sentence_Num, u_Pro_Config.n_Sentence_Start_Index);
- if (u_Pro_Config.USE_SILENCE_FEA == 1)
- {
- strcpy(sz_Silence_File_Name, sz_Feature_File_Name);
- int j = strlen(sz_Silence_File_Name) - 4;
- sz_Silence_File_Name[j] = ' ';
- strcat(sz_Silence_File_Name,"_sl.dat");
- nRetCode = dfa_Feature_Get_File_Info(sz_Silence_File_Name, &u_Feature_File_Head);
- ASSERT(nRetCode == 0);
- ASSERT(u_Feature_File_Head.sFeatureOrder == u_Pro_Config.n_Feature_Dim);
- n_Total_Frame_Num += dfa_Feature_Get_Silence_Total_Frame_Num(sz_Silence_File_Name, u_Pro_Config.n_Feature_Sentence_Num, u_Pro_Config.n_Sentence_Start_Index);
- }
- }
- // 为存放所有特征分配内存
- d2dda_All_Feature = d2dda_New(n_Total_Frame_Num, u_Pro_Config.n_Feature_Dim);
- // 读入所有特征
- n_Total_Frame_Index = 0;
- for (n_Person_Index = 0; n_Person_Index < u_Pro_Config.n_Feature_Person_Num; n_Person_Index++)
- {
- // 如果只用训练集的特征训练VQ码本,则跳过读取测试集特征
- if ((u_Pro_Config.l_VQ_Config & VQ_CONFIG_LOAD_ALL_FEATURE_METHOD_MASK) == VQ_CONFIG_LOAD_TRAIN_SET_ONLY)
- {
- if (u_Pro_Config.n_DHMM_Model_Person_Start_Index <= u_Pro_Config.n_DHMM_Model_Person_End_Index)
- {
- if ((n_Person_Index < u_Pro_Config.n_DHMM_Model_Person_Start_Index) || (n_Person_Index > u_Pro_Config.n_DHMM_Model_Person_End_Index)) continue;
- }
- else
- {
- if ((n_Person_Index > u_Pro_Config.n_DHMM_Model_Person_End_Index) && (n_Person_Index < u_Pro_Config.n_DHMM_Model_Person_Start_Index)) continue;
- }
- }
- else if ((u_Pro_Config.l_VQ_Config & VQ_CONFIG_LOAD_ALL_FEATURE_METHOD_MASK) == VQ_CONFIG_LOAD_ALL_FEATURE)
- {}
- sprintf(sz_Feature_File_Name, u_Pro_Config.sz_Feature_Origin_File_Name_Format, n_Person_Index);
- for(n_Sentence_Index = 0; n_Sentence_Index < u_Pro_Config.n_Feature_Sentence_Num; n_Sentence_Index++)
- {
- int Sen_Index = n_Sentence_Index + u_Pro_Config.n_Sentence_Start_Index;
- int framenum = dfa_Feature_Read_A_Sentence(sz_Feature_File_Name, Sen_Index, u_Pro_Config.n_Feature_Dim, &d2dda_All_Feature[n_Total_Frame_Index]);
- ASSERT(framenum >= 0);
- n_Total_Frame_Index += framenum;
- if (u_Pro_Config.USE_SILENCE_FEA == 1)
- {
- strcpy(sz_Silence_File_Name, sz_Feature_File_Name);
- int j = strlen(sz_Silence_File_Name) - 4;
- sz_Silence_File_Name[j] = ' ';
- strcat(sz_Silence_File_Name,"_sl.dat");
- framenum = dfa_Feature_Read_A_Silence(sz_Silence_File_Name, Sen_Index, u_Pro_Config.n_Feature_Dim, &d2dda_All_Feature[n_Total_Frame_Index]);
- ASSERT(framenum >= 0);
- n_Total_Frame_Index += framenum;
- }
- }
- }
- ASSERT(n_Total_Frame_Index == n_Total_Frame_Num);
- *pd2dda_Total_Feature = d2dda_All_Feature;
- *pn_Total_Feature_Num = n_Total_Frame_Num;
- return 0;
- }