00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 package com.meapsoft.featextractors;
00024
00025 import java.util.Arrays;
00026
00027 import com.meapsoft.STFT;
00028
00037 public class AvgMFCC extends AvgMelSpec
00038 {
00039 private int nceps = 13;
00040
00041
00042 public AvgMFCC()
00043 {
00044 super();
00045 }
00046
00047
00048 public double[] features(STFT stft, long startFrame, int length)
00049 {
00050 double[] mfccs = new double[nceps];
00051 Arrays.fill(mfccs, 0);
00052
00053
00054 int nmel = outDim;
00055 double m = Math.sqrt(2.0/nmel);
00056 double[][] DCTcoeffs = new double[nmel][nceps];
00057 for(int i = 0; i < nmel; i++)
00058 for(int j = 0; j < nceps; j++)
00059 DCTcoeffs[i][j] = m*Math.cos(Math.PI*(j+1)*(i+.5)/(double)nmel);
00060
00061 for(int frm = 0; frm < length; frm++)
00062 {
00063 double[] melSpec = super.features(stft, startFrame+frm, 1);
00064
00065
00066 for(int x = 0; x < melSpec.length; x++)
00067 {
00068
00069 melSpec[x] = melSpec[x]/10;
00070
00071
00072 for(int y = 0; y < mfccs.length; y++)
00073 mfccs[y] = mfccs[y] + DCTcoeffs[x][y]*melSpec[x]/length;
00074 }
00075 }
00076
00077 return mfccs;
00078 }
00079
00080 public String description()
00081 {
00082 return "Computes the mean MFCCs of a chunk, a commonly used feature in speech recognition.";
00083 }
00084 }