示例#1
0
        public List <SoundFeature> GetLPCAndCepstralSeries(string lpcNamePrefix, int lpcOrder, string cepstralNamePrefix, int cepstralOrder)
        {
            List <SoundFeature> lpcSoundFeatureList = new List <SoundFeature>();

            for (int ii = 0; ii < lpcOrder; ii++)
            {
                SoundFeature soundFeature = new SoundFeature();
                soundFeature.Name = lpcNamePrefix + (ii + 1).ToString(); // LPCs enumerated from 1.
                soundFeature.SetSize(frameList.Count);
                lpcSoundFeatureList.Add(soundFeature);
            }
            List <SoundFeature> cepstralSoundFeatureList = new List <SoundFeature>();

            for (int ii = 0; ii <= cepstralOrder; ii++)
            {
                SoundFeature soundFeature = new SoundFeature();
                soundFeature.Name = cepstralNamePrefix + ii.ToString();
                soundFeature.SetSize(frameList.Count);
                cepstralSoundFeatureList.Add(soundFeature);
            }
            List <double> lpcCoefficients = null;

            for (int iFrame = 0; iFrame < frameList.Count; iFrame++)
            {
                WAVSound frame = frameList[iFrame];
                lpcCoefficients = frame.ComputeLPCCoefficients(lpcOrder);
                for (int ii = 0; ii < lpcOrder; ii++)
                {
                    lpcSoundFeatureList[ii].ValueList[iFrame] = lpcCoefficients[ii];
                }
                List <double> cepstralCoefficients = frame.ComputeCepstralCoefficients(lpcCoefficients, cepstralOrder);
                for (int ii = 0; ii <= cepstralOrder; ii++)
                {
                    cepstralSoundFeatureList[ii].ValueList[iFrame] = cepstralCoefficients[ii];
                }
            }
            //
            // The first cepstral coefficient (c0) is equal to the (non-normalized) autocorrelation,
            // and can usually be removed in speech recognition (the autocorrelation is typically computed
            // elsewhere, as a separate feature).
            //
            // Moreover the second cepstral coefficient (c1) is identical to the first LPC coefficient,
            // and so can also be removed.
            //
            cepstralSoundFeatureList.RemoveAt(0); // Remove c0
            cepstralSoundFeatureList.RemoveAt(0); // Remove c1
            List <SoundFeature> soundFeatureList = new List <SoundFeature>();

            soundFeatureList.AddRange(lpcSoundFeatureList);
            soundFeatureList.AddRange(cepstralSoundFeatureList);
            return(soundFeatureList);
        }