/// <inheritdoc/>
 protected override void Receive(string text, Envelope e)
 {
     if (string.IsNullOrWhiteSpace(text))
     {
         this.Out.Post(new IntentData(), e.OriginatingTime);
     }
     else
     {
         var result = this.speechRecognitionEngine.EmulateRecognize(text);
         if (result != null && result.Semantics != null)
         {
             var intents = MicrosoftSpeech.BuildIntentData(result.Semantics);
             this.Out.Post(intents, e.OriginatingTime);
         }
     }
 }
Example #2
0
        /// <summary>
        /// Called when the final recognition result received.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">An object that contains the event data.</param>
        private void OnSpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            // Convention for intervals is to use the end time as the originating time so we add the duration as well.
            DateTime originatingTime = this.streamStartTime + e.Result.Audio.AudioPosition + e.Result.Audio.Duration;

            // Post the raw result from the underlying recognition engine
            this.PostWithOriginatingTimeConsistencyCheck(this.SpeechRecognized, e, originatingTime);

            if (e.Result.Alternates.Count > 0)
            {
                var result = this.BuildSpeechRecognitionResult(e.Result);
                this.PostWithOriginatingTimeConsistencyCheck(this.Out, result, originatingTime);

                if (e.Result.Semantics != null)
                {
                    var intents = MicrosoftSpeech.BuildIntentData(e.Result.Semantics);
                    this.PostWithOriginatingTimeConsistencyCheck(this.IntentData, intents, originatingTime);
                }
            }
        }