libsent/include/sent/mfcc.h File Reference

Definitions for MFCC computation. More...

#include <sent/stddefs.h>
#include <sent/htk_defs.h>
#include <ctype.h>

Go to the source code of this file.

Data Structures

struct  Value
 mfcc configuration parameter values More...
struct  FBankInfo
 Workspace for filterbank analysis. More...
struct  DeltaBuf
 Cycle buffer for delta computation. More...
struct  MFCCWork
 Work area for MFCC computation. More...
struct  CMEAN
 Structure to hold sentence sum of MFCC for realtime CMN. More...
struct  CMNWork
 Work area for real-time CMN. More...
struct  ENERGYWork
 work area for energy normalization on real time input More...

Defines

#define CPMAX   500
 DEBUG: define if you want to enable debug messages for sin/cos table operation.
#define CPSTEP   5
 allocate step of cmean list per sentence
#define DEF_SMPPERIOD   625
 Default sampling period in 100ns (625 = 16kHz).
#define DEF_FRAMESIZE   400
 Default Window size in samples, similar to WINDOWSIZE in HTK (unit is different).
#define DEF_FFTNUM   512
 Number of FFT steps.
#define DEF_FRAMESHIFT   160
 Default frame shift length in samples.
#define DEF_PREENPH   0.97
 Default pre-emphasis coefficient, corresponds to PREEMCOEF in HTK.
#define DEF_MFCCDIM   12
 Default number of MFCC dimension, corresponds to NUMCEPS in HTK.
#define DEF_CEPLIF   22
 Default cepstral Liftering coefficient, corresponds to CEPLIFTER in HTK.
#define DEF_FBANK   24
 Default number of filterbank channels, corresponds to NUMCHANS in HTK.
#define DEF_DELWIN   2
 Default delta window size, corresponds to DELTAWINDOW in HTK.
#define DEF_ACCWIN   2
 Default acceleration window size, corresponds to ACCWINDOW in HTK.
#define DEF_SILFLOOR   50.0
 Default energy silence floor in dBs, corresponds to SILFLOOR in HTK.
#define DEF_ESCALE   1.0
 Default scaling coefficient of log energy, corresponds to ESCALE in HTK.
#define DEF_SSALPHA   2.0
 Default alpha coefficient for spectral subtraction.
#define DEF_SSFLOOR   0.5
 Default flooring coefficient for spectral subtraction.
#define VALUE_VERSION   2
 Integer version number of Value, for embedding.

Functions

MFCCWorkWMP_work_new (Value *para)
 Setup work area for parameters, values, buffers, tables to compute MFCC vectors, with a given parameter configurations.
void WMP_calc (MFCCWork *w, float *mfcc, Value *para)
 Calculate MFCC and log energy for one frame.
void WMP_free (MFCCWork *w)
 Free all work area for MFCC computation.
void InitFBank (MFCCWork *w, Value *para)
 Build filterbank information and generate tables for MFCC comptutation.
void FreeFBank (FBankInfo *fb)
 Free FBankInfo.
void Hamming (float *wave, int framesize, MFCCWork *w)
 Apply hamming window.
void PreEmphasise (float *wave, int framesize, float preEmph)
 Apply pre-emphasis filter.
float Mel (int k, float fres)
 Return mel-frequency.
void FFT (float *xRe, float *xIm, int p, MFCCWork *w)
 Apply FFT.
void MakeFBank (float *wave, MFCCWork *w, Value *para)
 Convert wave -> (spectral subtraction) -> mel-frequency filterbank.
void MakeMFCC (float *mfcc, Value *para, MFCCWork *w)
 Apply DCT to filterbank to make MFCC.
float CalcC0 (MFCCWork *w, Value *para)
 Calculate 0'th cepstral coefficient.
float CalcLogRawE (float *wave, int framesize)
 Calculate Log Raw Energy.
void ZMeanFrame (float *wave, int framesize)
 Remove DC offset per frame.
void WeightCepstrum (float *mfcc, Value *para, MFCCWork *w)
 Re-scale cepstral coefficients.
int Wav2MFCC (SP16 *wave, float **mfcc, Value *para, int nSamples, MFCCWork *w)
 Convert wave data to MFCC.
void Delta (float **c, int frame, Value *para)
 Calculate delta coefficients.
void Accel (float **c, int frame, Value *para)
 Calculate acceleration coefficients.
void NormaliseLogE (float **c, int frame_num, Value *para)
 Normalise log energy.
void CMN (float **mfcc, int frame_num, int dim)
 Cepstrum Mean Normalization (buffered) Cepstral mean will be computed within the given MFCC vectors.
DeltaBufWMP_deltabuf_new (int veclen, int windowlen)
 Allocate a new delta cycle buffer.
void WMP_deltabuf_free (DeltaBuf *db)
 Destroy the delta cycle buffer.
void WMP_deltabuf_prepare (DeltaBuf *db)
 Reset and clear the delta cycle buffer.
boolean WMP_deltabuf_proceed (DeltaBuf *db, float *new_mfcc)
 Store the given MFCC vector into the delta cycle buffer, and compute the latest delta coefficients.
boolean WMP_deltabuf_flush (DeltaBuf *db)
 Flush the delta cycle buffer the delta coefficients left in the cycle buffer.
CMNWorkCMN_realtime_new (int dimension, float weight)
 Initialize MAP-CMN at startup.
void CMN_realtime_free (CMNWork *c)
 Free work area for real-time CMN.
void CMN_realtime_prepare (CMNWork *c)
 Prepare for MAP-CMN at start of each input.
void CMN_realtime (CMNWork *c, float *mfcc)
 Perform MAP-CMN for incoming MFCC vectors.
void CMN_realtime_update (CMNWork *c)
 Update initial cepstral mean from previous utterances for next input.
boolean CMN_load_from_file (CMNWork *c, char *filename)
 Load CMN parameter from file.
boolean CMN_save_to_file (CMNWork *c, char *filename)
 Save the current CMN vector to a file.
void energy_max_init (ENERGYWork *energy)
 Initialize work area for energy normalization on live input.
void energy_max_prepare (ENERGYWork *energy, Value *para)
 Prepare values for energy normalization on live input.
LOGPROB energy_max_normalize (ENERGYWork *energy, LOGPROB f, Value *para)
 Peform energy normalization using maximum of last input.
float * new_SS_load_from_file (char *filename, int *slen)
 Load a noise spectrum from file.
float * new_SS_calculate (SP16 *wave, int wavelen, int *slen, MFCCWork *w, Value *para)
 Compute average spectrum of audio input.
void undef_para (Value *para)
 Reset configuration parameters for MFCC computation.
void make_default_para (Value *para)
 Set Julius default parameters for MFCC computation.
void make_default_para_htk (Value *para)
 Set HTK default configuration parameters for MFCC computation.
void apply_para (Value *dst, Value *src)
 Merge two configuration parameters for MFCC computation.
boolean htk_config_file_parse (char *HTKconffile, Value *para)
 Read and parse an HTK Config file, and set the specified option values.
void calc_para_from_header (Value *para, short param_type, short vec_size)
 Set acoustic analysis parameters from HTK HMM definition header information.
void put_para (FILE *fp, Value *para)
 Output acoustic analysis configuration parameters to stdout.


Detailed Description

Definitions for MFCC computation.

This file contains structures and default values for extracting speech parameter vectors of Mel-Frequency Cepstral Cefficients (MFCC). The default values here are the ones used in the standard acoustic models distributed together with Julius, and some of them have different value from HTK defaults. So be careful of the default values.

See also:
libsent/src/wav2mfcc/wav2mfcc.c

libsent/src/wav2mfcc/wav2mfcc-pipe.c

julius/wav2mfcc.c

julius/realtime-1stpass.c

Author:
Akinobu LEE
Date:
Fri Feb 11 03:40:52 2005
Revision
1.1.1.1

Definition in file mfcc.h.


Define Documentation

#define CPMAX   500

DEBUG: define if you want to enable debug messages for sin/cos table operation.

Maximum number of frames to store ceptral mean for realtime CMN update

Definition at line 47 of file mfcc.h.

Referenced by CMN_realtime_update().


Function Documentation

MFCCWork* WMP_work_new ( Value para  ) 

Setup work area for parameters, values, buffers, tables to compute MFCC vectors, with a given parameter configurations.

Parameters:
para [in] configuration parameters
Returns:
pointer to the newly allocated work area.

Definition at line 537 of file mfcc-core.c.

Referenced by j_final_fusion(), and j_mfcccalc_new().

void WMP_calc ( MFCCWork w,
float *  mfcc,
Value para 
)

Calculate MFCC and log energy for one frame.

Perform spectral subtraction if ssbuf is specified.

Parameters:
w [i/o] MFCC calculation work area
mfcc [out] buffer to hold the resulting MFCC vector
para [in] configuration parameters

Definition at line 575 of file mfcc-core.c.

Referenced by RealTimeMFCC(), and Wav2MFCC().

void WMP_free ( MFCCWork w  ) 

Free all work area for MFCC computation.

Parameters:
w [i/o] MFCC calculation work area

Definition at line 617 of file mfcc-core.c.

Referenced by j_mfcccalc_free().

void InitFBank ( MFCCWork w,
Value para 
)

Build filterbank information and generate tables for MFCC comptutation.

Parameters:
w [i/o] MFCC calculation work area
para [in] configuration parameters
Returns:
the generated filterbank information.

Definition at line 169 of file mfcc-core.c.

void FreeFBank ( FBankInfo fb  ) 

Free FBankInfo.

Parameters:
fb [in] filterbank information

Definition at line 243 of file mfcc-core.c.

void Hamming ( float *  wave,
int  framesize,
MFCCWork w 
)

Apply hamming window.

Parameters:
wave [i/o] waveform data in the current frame
framesize [in] frame size
w [i/o] MFCC calculation work area

Definition at line 315 of file mfcc-core.c.

Referenced by new_SS_calculate().

void PreEmphasise ( float *  wave,
int  framesize,
float  preEmph 
)

Apply pre-emphasis filter.

Parameters:
wave [i/o] waveform data in the current frame
framesize [i/o] frame size in samples
preEmph [in] pre-emphasis coef.

Definition at line 299 of file mfcc-core.c.

Referenced by new_SS_calculate().

float Mel ( int  k,
float  fres 
)

Return mel-frequency.

Parameters:
k [in] channel number of filter bank
fres [in] constant value computed by "1.0E7 / (para.smp_period * fb.fftN * 700.0)"
Returns:
the mel frequency.

Definition at line 155 of file mfcc-core.c.

Referenced by InitFBank().

void FFT ( float *  xRe,
float *  xIm,
int  p,
MFCCWork w 
)

Apply FFT.

Parameters:
xRe [i/o] real part of waveform
xIm [i/o] imaginal part of waveform
p [in] 2^p = FFT point
w [i/o] MFCC calculation work area

Definition at line 336 of file mfcc-core.c.

Referenced by new_SS_calculate().

void MakeFBank ( float *  wave,
MFCCWork w,
Value para 
)

Convert wave -> (spectral subtraction) -> mel-frequency filterbank.

Parameters:
wave [in] waveform data in the current frame
w [i/o] MFCC calculation work area
para [in] configuration parameters

Definition at line 388 of file mfcc-core.c.

void MakeMFCC ( float *  mfcc,
Value para,
MFCCWork w 
)

Apply DCT to filterbank to make MFCC.

Parameters:
mfcc [out] output MFCC vector
para [in] configuration parameters
w [i/o] MFCC calculation work area

Definition at line 466 of file mfcc-core.c.

float CalcC0 ( MFCCWork w,
Value para 
)

Calculate 0'th cepstral coefficient.

Parameters:
w [i/o] MFCC calculation work area
para [in] configuration parameters
Returns:

Definition at line 448 of file mfcc-core.c.

float CalcLogRawE ( float *  wave,
int  framesize 
)

Calculate Log Raw Energy.

Parameters:
wave [in] waveform data in the current frame
framesize [in] frame size
Returns:
the calculated log raw energy.

Definition at line 279 of file mfcc-core.c.

void ZMeanFrame ( float *  wave,
int  framesize 
)

Remove DC offset per frame.

Parameters:
wave [i/o] waveform data in the current frame
framesize [in] frame size

Definition at line 260 of file mfcc-core.c.

Referenced by new_SS_calculate().

void WeightCepstrum ( float *  mfcc,
Value para,
MFCCWork w 
)

Re-scale cepstral coefficients.

Parameters:
mfcc [i/o] a MFCC vector
para [in] configuration parameters
w [i/o] MFCC calculation work area

Definition at line 500 of file mfcc-core.c.

int Wav2MFCC ( SP16 wave,
float **  mfcc,
Value para,
int  nSamples,
MFCCWork w 
)

Convert wave data to MFCC.

Also does spectral subtraction if ssbuf specified.

Parameters:
wave [in] waveform data
mfcc [out] buffer to store the resulting MFCC parameter vector [t][0..veclen-1], should be already allocated
para [in] configuration parameters
nSamples [in] length of waveform data
w [i/o] MFCC calculation work area
Returns:
the number of processed frames.

Definition at line 57 of file wav2mfcc-buffer.c.

Referenced by wav2mfcc().

void Delta ( float **  c,
int  frame,
Value para 
)

Calculate delta coefficients.

Parameters:
c [i/o] MFCC vectors, in which the delta coeff. will be appended.
frame [in] number of frames
para [in] configuration parameters

Definition at line 141 of file wav2mfcc-buffer.c.

Referenced by Wav2MFCC().

void Accel ( float **  c,
int  frame,
Value para 
)

Calculate acceleration coefficients.

Parameters:
c [i/o] MFCC vectors, in which the delta coeff. will be appended.
frame [in] number of frames
para [in] configuration parameters

Definition at line 179 of file wav2mfcc-buffer.c.

Referenced by Wav2MFCC().

void NormaliseLogE ( float **  mfcc,
int  frame_num,
Value para 
)

Normalise log energy.

Parameters:
mfcc [i/o] array of MFCC vectors
frame_num [in] number of frames
para [in] configuration parameters

Definition at line 109 of file wav2mfcc-buffer.c.

Referenced by Wav2MFCC().

void CMN ( float **  mfcc,
int  frame_num,
int  dim 
)

Cepstrum Mean Normalization (buffered) Cepstral mean will be computed within the given MFCC vectors.

Parameters:
mfcc [i/o] array of MFCC vectors
frame_num [in] number of frames
dim [in] total dimension of MFCC vectors

Definition at line 218 of file wav2mfcc-buffer.c.

Referenced by Wav2MFCC().

DeltaBuf* WMP_deltabuf_new ( int  veclen,
int  windowlen 
)

Allocate a new delta cycle buffer.

Parameters:
veclen [in] length of a vector
windowlen [in] window width for computing delta
Returns:
pointer to newly allocated delta cycle buffer structure.

Definition at line 59 of file wav2mfcc-pipe.c.

Referenced by RealTimeInit().

void WMP_deltabuf_free ( DeltaBuf db  ) 

Destroy the delta cycle buffer.

Parameters:
db [i/o] delta cycle buffer

Definition at line 86 of file wav2mfcc-pipe.c.

Referenced by j_mfcccalc_free().

void WMP_deltabuf_prepare ( DeltaBuf db  ) 

Reset and clear the delta cycle buffer.

Parameters:
db [i/o] delta cycle buffer

Definition at line 104 of file wav2mfcc-pipe.c.

Referenced by reset_mfcc().

boolean WMP_deltabuf_proceed ( DeltaBuf db,
float *  new_mfcc 
)

Store the given MFCC vector into the delta cycle buffer, and compute the latest delta coefficients.

Parameters:
db [i/o] delta cycle buffer
new_mfcc [in] MFCC vector
Returns:
TRUE if next delta coeff. computed, in that case it is saved in db->delta[], or FALSE if delta is not yet computed by short of data.

Definition at line 163 of file wav2mfcc-pipe.c.

Referenced by RealTimeMFCC(), and RealTimeParam().

boolean WMP_deltabuf_flush ( DeltaBuf db  ) 

Flush the delta cycle buffer the delta coefficients left in the cycle buffer.

Parameters:
db [i/o] delta cycle buffer
Returns:
TRUE if next delta coeff. computed, in that case it is saved in db->delta[], or FALSE if all delta computation has been flushed and no data is available.

Definition at line 205 of file wav2mfcc-pipe.c.

Referenced by RealTimeParam().

CMNWork* CMN_realtime_new ( int  dimension,
float  weight 
)

Initialize MAP-CMN at startup.

Parameters:
dimension [in] vector dimension
weight [in] initial cepstral mean weight

Definition at line 246 of file wav2mfcc-pipe.c.

Referenced by RealTimeInit().

void CMN_realtime_free ( CMNWork c  ) 

Free work area for real-time CMN.

Parameters:
c [i/o] CMN calculation work area

Definition at line 279 of file wav2mfcc-pipe.c.

Referenced by j_mfcccalc_free().

void CMN_realtime_prepare ( CMNWork c  ) 

Prepare for MAP-CMN at start of each input.

Parameters:
c [i/o] CMN calculation work area

Definition at line 298 of file wav2mfcc-pipe.c.

Referenced by RealTimePipeLinePrepare().

void CMN_realtime ( CMNWork c,
float *  mfcc 
)

Perform MAP-CMN for incoming MFCC vectors.

Parameters:
c [i/o] CMN calculation work area
mfcc [in] MFCC vector

Definition at line 314 of file wav2mfcc-pipe.c.

Referenced by RealTimeMFCC(), and RealTimeParam().

void CMN_realtime_update ( CMNWork c  ) 

Update initial cepstral mean from previous utterances for next input.

Parameters:
c [i/o] CMN calculation work area

Definition at line 343 of file wav2mfcc-pipe.c.

Referenced by RealTimeCMNUpdate().

boolean CMN_load_from_file ( CMNWork c,
char *  filename 
)

Load CMN parameter from file.

If the number of MFCC dimension in the file does not match the specified one, an error will occur.

Parameters:
c [i/o] CMN calculation work area
filename [in] file name
Returns:
TRUE on success, FALSE on failure.

Definition at line 443 of file wav2mfcc-pipe.c.

Referenced by RealTimeInit().

boolean CMN_save_to_file ( CMNWork c,
char *  filename 
)

Save the current CMN vector to a file.

Parameters:
c [i/o] CMN calculation work area
filename [in] filename to save the data.
Returns:
TRUE on success, FALSE on failure.

Definition at line 491 of file wav2mfcc-pipe.c.

Referenced by RealTimeCMNUpdate().

void energy_max_init ( ENERGYWork energy  ) 

Initialize work area for energy normalization on live input.

This should be called once on startup.

Parameters:
energy [in] energy normalization work area

Definition at line 533 of file wav2mfcc-pipe.c.

Referenced by RealTimeInit().

void energy_max_prepare ( ENERGYWork energy,
Value para 
)

Prepare values for energy normalization on live input.

This should be called before each input segment.

Parameters:
energy [in] energy normalization work area
para [in] MFCC computation configuration parameter

Definition at line 546 of file wav2mfcc-pipe.c.

Referenced by reset_mfcc().

LOGPROB energy_max_normalize ( ENERGYWork energy,
LOGPROB  f,
Value para 
)

Peform energy normalization using maximum of last input.

Parameters:
energy [in] energy normalization work area
f [in] raw energy
para [in] MFCC computation configuration parameter
Returns:
value of the normalized log energy.

Definition at line 563 of file wav2mfcc-pipe.c.

Referenced by RealTimeMFCC().

float* new_SS_load_from_file ( char *  filename,
int *  slen 
)

Load a noise spectrum from file.

Parameters:
filename [in] path name of noise spectrum file
slen [out] length of the returned buffer
Returns:
a newly allocated buffer that holds the loaded noise spectrum.

Definition at line 66 of file ss.c.

Referenced by RealTimeInit(), and wav2mfcc().

float* new_SS_calculate ( SP16 wave,
int  wavelen,
int *  slen,
MFCCWork w,
Value para 
)

Compute average spectrum of audio input.

This is used to estimate a noise spectrum from input samples.

Parameters:
wave [in] input audio data sequence
wavelen [in] length of above
slen [out] length of returned buffer
w [i/o] MFCC calculation work area
para [in] parameter
Returns:
a newly allocated buffer that contains the calculated spectrum.

Definition at line 111 of file ss.c.

Referenced by wav2mfcc().

void undef_para ( Value para  ) 

Reset configuration parameters for MFCC computation.

Parameters:
para [out] feature extraction parameters

Definition at line 39 of file para.c.

Referenced by initialize_GSHMM(), and jconf_set_default_values_am().

void make_default_para ( Value para  ) 

Set Julius default parameters for MFCC computation.

Parameters:
para [out] feature extraction parameters

Definition at line 80 of file para.c.

Referenced by jconf_set_default_values_am().

void make_default_para_htk ( Value para  ) 

Set HTK default configuration parameters for MFCC computation.

This will be refered when parameters are given as HTK Config file.

Parameters:
para [out] feature extraction parameters

Definition at line 110 of file para.c.

Referenced by jconf_set_default_values_am().

void apply_para ( Value dst,
Value src 
)

Merge two configuration parameters for MFCC computation.

Parameters:
dst [out] feature extraction parameters to set to
src [out] feature extraction parameters to set from

Definition at line 135 of file para.c.

Referenced by initialize_GMM(), and initialize_HMM().

boolean htk_config_file_parse ( char *  HTKconffile,
Value para 
)

Read and parse an HTK Config file, and set the specified option values.

Parameters:
HTKconffile [in] HTK Config file path name
para [out] MFCC parameter to set
Returns:
TRUE on success, FALSE on failure.

Definition at line 178 of file para.c.

Referenced by opt_parse().

void calc_para_from_header ( Value para,
short  param_type,
short  vec_size 
)

Set acoustic analysis parameters from HTK HMM definition header information.

Parameters:
para [out] acoustic analysis parameters
param_type [in] parameter type specified at HMM header
vec_size [in] vector size type specified at HMM header

Definition at line 288 of file para.c.

Referenced by initialize_GMM(), and initialize_HMM().

void put_para ( FILE *  fp,
Value para 
)

Output acoustic analysis configuration parameters to stdout.

Parameters:
fp [in] file pointer
para [in] configuration parameter

Definition at line 324 of file para.c.

Referenced by print_engine_info().


Generated on Tue Dec 18 16:01:36 2007 for Julius by  doxygen 1.5.4