private List <int> getLastResult(KIOSResult last) { List <int> result = new List <int>(); if (last != null) { string[] text = last.CleanText.Split(' '); foreach (var item in text) { string lower = item.ToLower().Trim(); switch (lower) { case "zero": case "0": result.Add(0); break; case "one": result.Add(1); break; case "two": result.Add(2); break; case "three": result.Add(3); break; case "four": result.Add(4); break; case "five": result.Add(5); break; case "six": result.Add(6); break; case "seven": result.Add(7); break; case "eight": result.Add(8); break; case "nine": result.Add(9); break; } } } return(result); }
public override void RecognizerPartialResult(KIOSResult result, KIOSRecognizer recognizer) { // RPC 14Mar2018 #700 Support Silence detection if (fSpeechRecognitionRunning) { lastSpeechResult = DateTime.Now; } System.Diagnostics.Debug.WriteLine("ASR: Partial " + result.CleanText); }
public void stopListeningAndReturnResultWhenReady(int testCard) { // RPC 14Mar2018 #700 Support Silence detection fSpeechRecognitionRunning = false; Task.Run(() => { var test = recognizer.RecognizerState; System.Diagnostics.Debug.WriteLine("Before calling stopListeningAndReturn, Recognizer state is " + test); lastResult = recognizer.StopListeningAndReturnFinalResult(); var lst = lastResult; if (lst != null) { System.Diagnostics.Debug.WriteLine("---------------------"); if (lst.Words != null) { foreach (var word in lst.Words) { System.Diagnostics.Debug.Write(" " + word.Text + " " + word.StartTime + " " + word.Duration); } } System.Diagnostics.Debug.WriteLine("---------------------"); } var ret = new ASRReturn(); ret.FileName = GetLastRecordingFilename(); ret.Result = getLastResult(lst); ret.TestCardNumber = testCard; string jsonFileName = recognizer.LastJSONMetadataFilename; if (jsonFileName != null) { ret.jsonResult = File.ReadAllText(jsonFileName); } else { ret.jsonResult = ""; } MessagingCenter.Send <IASR, ASRReturn>(this, "RecordingStopped", ret); // i reworked this to get the filename and results from withing this thread }); }
public void RecognizerFinalResult(KIOSResult result, KIOSRecognizer recognizer) { System.Diagnostics.Debug.WriteLine("Final"); }