示例#1
0
        public static void getFeatures(string mkcollection)
        {
            string bextractArgs = "-fe -n -ws " + WINDOW_FS + " -hp " + WINDOW_FS + " -od " + ExecutableInformation.getTmpPath() + "/" + " " + mkcollection;

            System.Diagnostics.Process bextract = new System.Diagnostics.Process();
            bextract.StartInfo.WindowStyle            = System.Diagnostics.ProcessWindowStyle.Hidden;
            bextract.StartInfo.UseShellExecute        = false;
            bextract.StartInfo.RedirectStandardOutput = false;
            bextract.StartInfo.Arguments = bextractArgs;
            bextract.StartInfo.FileName  = ExecutableInformation.getBExtractPath();

            bextract.Start();
            bextract.WaitForExit();
        }
示例#2
0
        static void Main(string[] args)
        {
            //Music directory
            string directory = @"T:\Documents\music-classifier\clips_45seconds";

            //Expected energy output
            //Input file is comma separated in the following format:
            //  song1,expectedEnergy,expectedPositivity
            //  song2,expectedEnergy,expectedPositivity
            //
            //song1 is expected to be the filename of the song, and the file is expected to be in the same directory as the csv
            //so if song1 is "hello.mp3", a hello.mp3 file should be in the directory that the csv is located
            List <Song> expectedOutputs = new List <Song>();

            string[] energyLines = System.IO.File.ReadAllLines(@"T:\Documents\music-classifier\clips_45seconds\expected_energy_positivity_random.csv");
            foreach (string line in energyLines)
            {
                string[] parts              = line.Split(',');
                string   songPath           = Path.Combine(directory, parts[0]);
                double   expectedEnergy     = double.Parse(parts[1]);
                double   expectedPositivity = double.Parse(parts[2]);

                Classifier.Song song = new Classifier.Song();
                song.positivity = expectedPositivity;
                song.energy     = expectedEnergy;
                song.title      = songPath;
                expectedOutputs.Add(song);
            }

            //Train
            Classifier.SupportVectorMachine classifier = new Classifier.SupportVectorMachine();
            classifier.Train(expectedOutputs);

            //Save classifier
            classifier.SaveModels(Path.Combine(ExecutableInformation.getTmpPath(), "positivity.svm"), Path.Combine(ExecutableInformation.getTmpPath(), "energy.svm"));
        }