示例#1
0
        private async void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();

            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            using (var stream = new FileStream(ofd.FileName, FileMode.Open))
            {
                var waveFile = new WaveFile(stream, true);
                _signal = waveFile[Channels.Left];
            }

            var sr        = _signal.SamplingRate;
            var barkbands = FilterBanks.BarkBands(16, 512, sr, 100 /*Hz*/, 6500 /*Hz*/, overlap: false);
            var barkbank  = FilterBanks.Triangular(512, sr, barkbands);

            var mfccExtractor = new MfccExtractor(_signal.SamplingRate, 13,
                                                  //filterbankSize: 40,
                                                  //lowFreq: 100,
                                                  //highFreq: 4200,
                                                  //lifterSize: 22,
                                                  preEmphasis: 0.97,
                                                  //filterbank: barkbank,
                                                  window: WindowTypes.Hamming);

            _mfccVectors = mfccExtractor.ComputeFrom(_signal);

            //FeaturePostProcessing.NormalizeMean(_mfccVectors);        // optional
            //FeaturePostProcessing.AddDeltas(_mfccVectors);

            FillFeaturesList(_mfccVectors, mfccExtractor.FeatureDescriptions);
            mfccListView.Items[0].Selected = true;

            melFilterBankPanel.Groups = mfccExtractor.FilterBank;

            mfccPanel.Line = _mfccVectors[0].Features;

            using (var csvFile = new FileStream("mfccs.csv", FileMode.Create))
            {
                var header = mfccExtractor.FeatureDescriptions;
                //.Concat(mfccExtractor.DeltaFeatureDescriptions)
                //.Concat(mfccExtractor.DeltaDeltaFeatureDescriptions);

                var serializer = new CsvFeatureSerializer(_mfccVectors, header);
                await serializer.SerializeAsync(csvFile);
            }
        }
示例#2
0
        private async void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();

            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            using (var stream = new FileStream(ofd.FileName, FileMode.Open))
            {
                var waveFile = new WaveFile(stream, true);
                _signal = waveFile[Channels.Left];
            }

            var mfccExtractor = new MfccExtractor(13,
                                                  //frameSize: 0.03125,
                                                  //hopSize: 0.015625,
                                                  melFilterbankSize: 20,
                                                  //lowFreq: 100,
                                                  //highFreq: 4200,
                                                  //lifterSize: 22,
                                                  preEmphasis: 0.95,
                                                  window: WindowTypes.Hamming);

            _mfccVectors = mfccExtractor.ComputeFrom(_signal);

            //FeaturePostProcessing.NormalizeMean(_mfccVectors);
            //FeaturePostProcessing.AddDeltas(_mfccVectors);

            FillFeaturesList(_mfccVectors, mfccExtractor.FeatureDescriptions);
            mfccListView.Items[0].Selected = true;

            melFilterBankPanel.Groups = mfccExtractor.FilterBank;

            mfccPanel.Line = _mfccVectors[0].Features;

            using (var csvFile = new FileStream("mfccs.csv", FileMode.Create))
            {
                var header = mfccExtractor.FeatureDescriptions
                             .Concat(mfccExtractor.DeltaFeatureDescriptions)
                             .Concat(mfccExtractor.DeltaDeltaFeatureDescriptions);

                var serializer = new CsvFeatureSerializer(_mfccVectors, header);
                await serializer.SerializeAsync(csvFile);
            }
        }