?? gauss_main.cpp
字號(hào):
/*
//
// 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 Gaussian Mixture 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.
//
//
// Test of Vector Gaussian Mixture Calculation
//
//
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ipps.h>
#include <ippsr.h>
#include <ippcore.h>
#include "len_stat.h"
#include "fake_decoder.h"
#include "prob_cache.h"
#include "prob_calc.h"
#include "feat_calc.h"
static int frequency = 500;
static int TypeTest = 0;
static int num_err = 0;
#if defined( _WIN32 ) || defined( _WIN64 )
#define IPP_MAX_64U ( 0xffffffffffffffffL ) //18446744073709551615
#else
#define IPP_MAX_64U ( 0xffffffffffffffffLL ) //18446744073709551615
#endif
float getUSec(Ipp64u s, Ipp64u e) { // returns (CPU_Frequency * time_in_sec)
#if defined __ICL
Ipp64f b=((s<e)?(e-s):((IPP_MAX_64U-s)+e))/1000000.0;
#else // MSVC 6.0 could not divide int64 by double
Ipp64u a=(s<e)?(e-s):((IPP_MAX_64U-s)+e);
Ipp64f b=((Ipp32u)(a>>32)*((Ipp64f)IPP_MAX_32U+1.0)+(Ipp32u)(a&IPP_MAX_32U))/1000000.0;
#endif
return (float)b;
}
static bool ParseCommLine (int argc, char *argv[])
{
if (argc < 2) return false;
while (argc>=2)
{
if (strcmp(*argv,"-f")==0) {
frequency = atoi(*(argv+1));
if(0 == frequency) frequency=500;
argc-=2;
argv+=2;
continue;
}
if (strcmp(*argv,"-t")==0) {
TypeTest = atoi(*(argv+1));
argc-=2;
argv+=2;
continue;
}
printf("WARNING:unrecognised parameter %s \n",*argv);
argc--;
argv++;
}
return true;
}
char* Fake_Decoder_Test
(Calc_Hint hint, // probability calculation method:
// calcNone - no calculations
// calcVect - LogGauss & LogAdd calculations
// calcVecM - LogGauss & LogMax calculations
// calcMix - LogGaussMixture calculations
char *paramfile, // mixture param file name or "" for fake model
char *featfile, // HTK feature file name or "" for fake features
int mixnum, // state (mixture) number for fake model
int gaussnum, // Gaussian number per mixture for fake model
int dimension, // feature space dimension for fake model or features
int calcmax, // maximal probability vector length for calculator
int calcmin, // minimal probability vector length (except end)
int framenum, // frame number for fake features
int delay, // maximal portion of features
int cachelen, // cache length (frames)
int veclen, // probability vector length in cache
int actlen, // maximal state activity interval
int avrmix, // average active states per frame
char *problogfile, // probability log file name or "" for fake features
char *featlogfile) // HTK feature file name or "" for fake features
{
int t,num,avl;
Ipp64u m_clocks;
double sec_time;
double speech_sec;
float freq=(float)frequency;
int model=0;
Len_Stat stat_dec;
Len_Stat stat_cache;
Prob_Calc *calc= new Prob_Calc(hint);
if (paramfile[0]==0) {
if (calc->Init_Calc(mixnum,gaussnum,dimension,calcmax,calcmin)<0){
num_err++;
return "ERROR! Could not create fake mixture calculator\n";
}
model=0;
} else {
if (calc->Init_Calc(paramfile,calcmax,calcmin)<0){
num_err++;
return "ERROR! Could not create SDT mixture calculator\n";
}
model=1;
mixnum=calc->State_Number();
dimension=calc->Feature_Length();
gaussnum=calc->Max_Gauss();
}
if (calc->Init_LogFile(featlogfile)<0){
num_err++;
return "ERROR! Could not open feature log file\n";
}
Feat_Calc *feat= new Feat_Calc(dimension,delay);
if (featfile[0]==0) {
if (feat->Init_Feat(framenum)<0){
num_err++;
return "ERROR! Could not create fake feature producer\n";
}
} else {
if (feat->Init_Feat(featfile)<0){
num_err++;
return "Could not create HTK file feature producer\n";
}
}
if (!calc->Attach_Feat(feat)){
num_err++;
return "Could not attach feature producer\n";
}
Prob_Cache *cache= new Prob_Cache(mixnum,veclen,cachelen);
if (cache->Init_Cache()<0){
num_err++;
return "ERROR! Could not create probabilities cache\n";
}
if (!cache->Attach_Calc(calc)){
num_err++;
return "ERROR! Could not attach mixture calculator\n";
}
Fake_Decoder *dec = new Fake_Decoder(mixnum,actlen);
if (dec->Init_Decoder()<0){
num_err++;
return "ERROR! Could not create fake decoder\n";
}
if (!dec->Attach_Cache(cache)){
num_err++;
return "Could not attach probabilities cache\n";
}
if (dec->Init_LogFile(problogfile)<0){
num_err++;
return "ERROR! Could not open probability log file\n";
}
stat_dec.len=256;
stat_dec.nums=(int*)calloc(sizeof(int),256);
stat_cache.len=veclen;
stat_cache.nums=(int*)calloc(sizeof(int),veclen);
m_clocks=ippGetCpuClocks();
framenum=1;
while (dec->Decode_Frame(avrmix)) {
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -