Ejemplo n.º 1
0
        /// <summary>
        /// Event handler function for conversation errors.
        /// Will raise the status event with the error message
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnConversationErrorReceived(object sender, SpeechErrorEventArgs e)
        {
            if (_isMicRecording)
            {
                StopMicRecording();
            }

            string message             = $"Speech to text failed with status code: {e.SpeechErrorCode.ToString()}, and error message: {e.SpeechErrorText}";
            SpeechToTextEventArgs args = new SpeechToTextEventArgs(SttStatus.Error, message);

            RaiseSttStatusUpdated(args);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Event handler function to handle responses. Will add phrases to a list
        /// and publish them with the status event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnResponseReceived(object sender, SpeechResponseEventArgs e)
        {
            if (_isMicRecording)
            {
                StopMicRecording();
            }

            RecognizedPhrase[] recognizedPhrases = e.PhraseResponse.Results;
            List <string>      phrasesToDisplay  = new List <string>();

            foreach (RecognizedPhrase phrase in recognizedPhrases)
            {
                phrasesToDisplay.Add(phrase.DisplayText);
            }

            SpeechToTextEventArgs args = new SpeechToTextEventArgs(SttStatus.Success, $"STT completed with status: {e.PhraseResponse.RecognitionStatus.ToString()}", phrasesToDisplay);

            RaiseSttStatusUpdated(args);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Event handler function for intents. Raises a status event with the received intent
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnIntentReceived(object sender, SpeechIntentEventArgs e)
        {
            SpeechToTextEventArgs args = new SpeechToTextEventArgs(SttStatus.Success, $"Intent received: {e.Intent.ToString()}.\nPayload: {e.Payload}");

            RaiseSttStatusUpdated(args);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Helper function to raise OnSttStatusUpdated events
 /// </summary>
 /// <param name="args"></param>
 private void RaiseSttStatusUpdated(SpeechToTextEventArgs args)
 {
     OnSttStatusUpdated?.Invoke(this, args);
 }