protected void Page_Load(object sender, EventArgs e) { foreach (string upload in Request.Files) { // Get target word string targetWord = Request.Form["target"]; // Upload audio file string dictionary = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"uploads"); Directory.CreateDirectory(dictionary); var file = Request.Files[upload]; if (file == null) { continue; } string recordingPath = Path.Combine(dictionary, Request.Form["fileName"]); file.SaveAs(recordingPath); // Analyse audio file HTKEngine engine = new HTKEngine(); Dictionary <string, string> htkResult = engine.Recognize(recordingPath).ToDictionary(x => x.Key, x => x.Value); Console.WriteLine(recordingPath); // Convert results to JSON string result = ""; if (htkResult.Count == 0) { result = "nothing"; } else { result = htkResult.Values.ToArray()[0]; } // Add scores to database. MPAiSQLite context = new MPAiSQLite(); context.SaveScore(System.Web.HttpContext.Current.User.Identity.Name, targetWord.ToLower(), (int)(Math.Round(SimilarityAlgorithm.DamereauLevensheinDistanceAlgorithm(Request.Form["target"], result) * 100, 0))); // Output result as JSON. Response.Clear(); Response.ContentType = "application/json; charset=utf-8"; Response.Write(GetResponse(Request.Form["target"], result)); Response.End(); } }