static void Main(string[] args) { double[][] inputs = { }; int[] outputs = { }; if (LearningModel.doTraining) { for (int i = 1; i <= Training.LearningModel.noteCount; i++) { string training_file = "C:\\UCLA\\MrChorder-master\\MrChorder\\Training\\LearningModelData\\piano" + i.ToString() + ".wav"; OnsetDetector onsetDetector = new OnsetDetector(training_file, null); double[][] FAData = onsetDetector.GenerateTrainingFAData(); inputs = ConcatVector(inputs, FAData); int[] arr = new int[FAData.Length]; for (int j = 0; j < arr.Length; j++) { arr[j] = i - 1; } outputs = ConcatElement(outputs, arr); Console.WriteLine("Training FA Data generated."); } } LearningModel svm = new LearningModel(inputs, outputs); Console.WriteLine("Testing."); string testFile = "C:\\UCLA\\MrChorder-master\\MrChorder\\Training\\LearningModelData\\test3.wav"; OnsetDetector testDetector = new OnsetDetector(testFile, svm); double[][] notes = testDetector.GenerateNotes(); double[][] labels = { }; foreach (string line in File.ReadLines("C:\\UCLA\\MrChorder-master\\MrChorder\\Training\\LearningModelData\\label3", Encoding.UTF8)) { double[][] t = new double[1][]; t[0] = new double[2]; string[] s = line.Split(' '); t[0][0] = Double.Parse(s[0]); t[0][1] = Double.Parse(s[1]); labels = ConcatVector(labels, t); } double[] acc = GetAccuracy(notes, labels); Console.WriteLine("End"); }
public void SendFile() { // Process file. string resultFilePath = System.IO.Path.Combine(Server.MapPath("~\\Generate\\"), System.IO.Path.GetFileName("AnalyseResult.pdf")); while (!System.IO.File.Exists(resultFilePath)) { // TODO(allenxie): Fancy work on filename processing. double[][] inputs = { }; int[] outputs = { }; LearningModel svm = new LearningModel(inputs, outputs); // Pre-trained OnsetDetector od = new OnsetDetector(filename, svm); double[][] music = od.GenerateNotes(); for (int i = 0; i < music.Length; i++) { music[i][0] = music[i][0] + 1; // Sync Training module and ToPDF module } ToPDF PDFGenerator = new ToPDF(resultFilePath, music, music.Length, musicname); } Response.Write("Return file successfully!"); Response.End(); }