예제 #1
0
        public void Predict(string file)
        {
            ExtractMFCC.ReadWav(file, out double[] L, out double[] R);
            var mfcc = ExtractMFCC.MFCC_20_calculation(L);

            float[] pred = Model.predict(mfcc)[0].To <float[]>();
        }
예제 #2
0
        public void InitialData()
        {
            int i = 0;

            foreach (string folder in Directory.GetFiles(TrainPath))
            {
                foreach (string file in Directory.GetFiles(folder))
                {
                    ExtractMFCC.ReadWav(file, out double[] L, out double[] R);
                    TrainData.Add(ExtractMFCC.MFCC_20_calculation(L));
                    TrainLabels.Add(i);
                }
                i++;
            }
            i = 0;
            foreach (string folder in Directory.GetFiles(ValidatePath))
            {
                foreach (string file in Directory.GetFiles(folder))
                {
                    ExtractMFCC.ReadWav(file, out double[] L, out double[] R);
                    ValidData.Add(ExtractMFCC.MFCC_20_calculation(L));
                    TrainLabels.Add(i);
                }
                i++;
            }
            foreach (var t in TrainData)
            {
                if (t.Length / 20 != ExtractMFCC.countFramesMax)
                {
                    t.Add(new double[(ExtractMFCC.countFramesMax - (t.Length / 20)), 20]);
                }
            }
            foreach (var t in TrainData)
            {
                if (t.Length / 20 != ExtractMFCC.countFramesMax)
                {
                    t.Add(new double[(ExtractMFCC.countFramesMax - (t.Length / 20)), 20]);
                }
            }
        }