Exemplo n.º 1
0
 static void ClassifyAndDump(short[] signal, SignalClassifier classifier, string folder, string fileName)
 {
     var result = classifier.Classify(signal).Select(ConvertClassMark).ToArray();
     var dump = new WavFileInfo(DefaultSampleRate, result);
     var filePath = string.Concat(folder, fileName, "_result", ".wav");
     dump.Write(filePath);
 }
Exemplo n.º 2
0
        private static void ClassifyAll(string folder, string[] fileNames, SignalClassifier classifier)
        {
            foreach (var fileName in fileNames)
            {
                var wavFile = WavFileInfo.Read(string.Concat(folder, fileName, ".wav"));
                if (wavFile.SampleRate != DefaultSampleRate)
                {
                    throw new Exception(string.Format("File {0} has non-default sample rate", fileName));
                }
                ClassifyAndDump(wavFile.Data, classifier, folder, fileName);

                var markerFile = MarkerFileInfo.Read(string.Concat(folder, fileName, ".mrk"));
                var expectedWavFile = new WavFileInfo(wavFile.SampleRate,
                                                      markerFile.Decompress(wavFile.Data.Length)
                                                                .Select(ConvertClassMark)
                                                                .ToArray());
                expectedWavFile.Write(string.Concat(folder, fileName, "_expected", ".wav"));
            }
        }
Exemplo n.º 3
0
 static void ExtractAndDump(short[] signal, IFeatureExtractor featureExtractor, string folder, string fileName)
 {
     var feature = featureExtractor.Extract(signal);
     var dump = new WavFileInfo(DefaultSampleRate, feature);
     var filePath = string.Concat(folder, fileName, featureExtractor.FeatureName, ".wav");
     dump.Write(filePath);
 }