⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gmm_main.cpp

📁 Intel开发的IPP库的应用实例
💻 CPP
字号:
/*
//
//                  INTEL CORPORATION PROPRIETARY INFORMATION
//     This software is supplied under the terms of a license agreement or
//     nondisclosure agreement with Intel Corporation and may not be copied
//     or disclosed except in accordance with the terms of that agreement.
//          Copyright(c) 1999-2006 Intel Corporation. All Rights Reserved.
//
//     Intel(R) Integrated Performance Primitives Speech Processing Sample for Windows*
//
//  By downloading and installing this sample, you hereby agree that the
//  accompanying Materials are being provided to you under the terms and
//  conditions of the End User License Agreement for the Intel(R) Integrated
//  Performance Primitives product previously accepted by you. Please refer
//  to the file ippEULA.rtf located in the root directory of your Intel(R) IPP
//  product installation for more information.
//
*/

//---------------------------------------------------------------------
//          GMM training & speaker verification program  main
//---------------------------------------------------------------------

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ipps.h>
#include <ippsr.h>
#include "gmm.h"

#define TRAIN_MIXTURE true
#define SAVE_MIXTURE true
#define TRAIN_CYCLES 3
#define MIXTURE_SIZE 128
#define CUT_ENERGY true
#define TRAIN_NUM 4
#define TEST_NUM 10

char *MixFileList[TRAIN_NUM]={//saved mixtures file list
    "..\\data\\gmm_trn_1.mix",
    "..\\data\\gmm_trn_2.mix",
    "..\\data\\gmm_trn_3.mix",
    "..\\data\\gmm_trn_4.mix"};
char *TrainFileList[TRAIN_NUM]={//train file list ~1200 frames each file
    "..\\data\\gmm_trn_1.mfc",
    "..\\data\\gmm_trn_2.mfc",
    "..\\data\\gmm_trn_3.mfc",
    "..\\data\\gmm_trn_4.mfc"};
char *TestFileList[TEST_NUM]={//test file list, different with train corpus
    "..\\data\\gmm_tst_1.mfc",
    "..\\data\\gmm_tst_2.mfc",
    "..\\data\\gmm_tst_3.mfc",
    "..\\data\\gmm_tst_4.mfc",
    "..\\data\\gmm_tst_5.mfc",
    "..\\data\\gmm_tst_6.mfc",
    "..\\data\\gmm_tst_7.mfc",
    "..\\data\\gmm_tst_8.mfc",
    "..\\data\\gmm_tst_9.mfc",
    "..\\data\\gmm_tst_10.mfc"};

int main(int argc, char *argv[]){
  GMM     gmm[TRAIN_NUM];
  int     i,j;
     if(TRAIN_MIXTURE){// train mixture with mfcc file
        for(j=0;j<TRAIN_NUM;++j){
            printf("\nMixture training for speaker %d started with %s file\n",
               j+1,TrainFileList[j]);
            gmm[j].InitMixWithCDBK(TrainFileList[j],MIXTURE_SIZE,CUT_ENERGY);
            printf("\nMixture training for speaker %d finished - %d cycles, %d Gaussians\n",
               j+1,TRAIN_CYCLES,gmm[j].GaussianNum());
            gmm[j].TrainMix(TRAIN_CYCLES);
            if(SAVE_MIXTURE){
                gmm[j].WriteMix(MixFileList[j]);
                printf("\nMixture for speaker %d saved to %s file\n",j+1,MixFileList[j]);
            }
            printf("\n");
            for(i=0;i<TEST_NUM;++i){//evaluate loglikelihood per frame on test feature set
                printf("Speaker %2d - likelihood per frame %7.3f file %s \n",
                   i+1,gmm[j].LogLHPerFrame(TestFileList[i]),TestFileList[i]);
            }
        }
     }else{//read mixture from param file
        for(j=0;j<TRAIN_NUM;++j){
            gmm[j].ReadMix(MixFileList[j]);
            printf("\nMixture for speaker %d read from %s file - %d Gaussians\n",
               j+1,MixFileList[j],gmm[j].GaussianNum());
            printf("\n");
            for(i=0;i<TEST_NUM;++i){//evaluate loglikelihood per frame on test feature set
                printf("Speaker %2d - likelihood per frame %7.3f file %s \n",
                   i+1,gmm[j].LogLHPerFrame(TestFileList[i]),TestFileList[i]);
            }
        }
     }
   return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -