/// <summary> /// Initializes a new instance of the RecognizedSpeechMessage class. /// </summary> /// <param name="args">Event arguments.</param> internal RecognizedSpeechMessage(SpeechRecognizedEventArgs args) { this.category = SpeechStreamHandler.SpeechEventCategory; this.eventType = "recognized"; SpeechSemanticValue semanticValue = null; try { semanticValue = new SpeechSemanticValue(args.Result.Semantics); } catch (InvalidOperationException) { // Failed to parse semantics, leave it empty. } this.recognized = new MessageArgs { grammar = args.Result.Grammar.Name, text = args.Result.Text, confidence = args.Result.Confidence, semantics = semanticValue, alternates = SpeechRecognizedPhrase.CreateArray(args.Result.Alternates), words = SpeechWord.CreateArray(args.Result.Words) }; }
/// <summary> /// Allocates and initializes an array of SpeechRecognizedPhrase objects. /// </summary> /// <param name="phrases">The colleciton of phrases from the speech recognition engine.</param> /// <returns>A new array of SpeechRecognizedPhrase objects</returns> public static SpeechRecognizedPhrase[] CreateArray(ICollection <RecognizedPhrase> phrases) { var array = new SpeechRecognizedPhrase[phrases.Count]; int i = 0; foreach (var phrase in phrases) { array[i++] = new SpeechRecognizedPhrase(phrase); } return(array); }