Пример #1
0
        public void Start()
        {
            _client?.Dispose();

            _client = SpeechRecognitionServiceFactory.CreateDataClient(
                SpeechRecognitionMode.LongDictation,
                _speechSettings.SpeechLanguage,
                _speechSettings.AzureSpeechPrimaryKey /*, _speechSettings.AzureSpeechSecondaryKey,_speechSettings.AzureSpeechAuthUrl*/);

            _started = true;
            ;
            _client.SendAudioFormat(SpeechAudioFormat.create16BitPCMFormat(_speechSettings.SampleRateValue));

            _client.OnResponseReceived += ClientOnResponseReceived;
        }
Пример #2
0
        /// <summary>
        /// Raises the System.Windows.Window.Closed event.
        /// </summary>
        /// <param name="e">An System.EventArgs that contains the event data.</param>
        protected override void OnClosed(EventArgs e)
        {
            _dataClient?.Dispose();
            _micClient?.Dispose();

            base.OnClosed(e);
        }
Пример #3
0
        /// <summary>
        //  Raises the System.Windows.Window.Closed event.
        /// </summary>
        /// <param name="e">An System.EventArgs that contains the event data.</param>
        protected override void OnClosed(EventArgs e)
        {
            if (null != _dataClient)
            {
                _dataClient.Dispose();
            }

            if (null != _micClient)
            {
                _micClient.Dispose();
            }

            _FinalResponseEvent.Dispose();

            base.OnClosed(e);
        }
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_micRecClient != null)
                {
                    _micRecClient.EndMicAndRecognition();

                    _micRecClient.OnMicrophoneStatus        -= OnMicrophoneStatus;
                    _micRecClient.OnPartialResponseReceived -= OnPartialResponseReceived;
                    _micRecClient.OnResponseReceived        -= OnResponseReceived;
                    _micRecClient.OnConversationError       -= OnConversationErrorReceived;

                    _micRecClient.Dispose();
                    _micRecClient = null;
                }

                if (_dataRecClient != null)
                {
                    _dataRecClient.OnIntent -= OnIntentReceived;
                    _dataRecClient.OnPartialResponseReceived -= OnPartialResponseReceived;
                    _dataRecClient.OnConversationError       -= OnConversationErrorReceived;
                    _dataRecClient.OnResponseReceived        -= OnResponseReceived;

                    _dataRecClient.Dispose();
                    _dataRecClient = null;
                }
            }
        }
Пример #5
0
 public void Stop()
 {
     try
     {
         micClient.AudioStop();
         micClient.Dispose();
         dataClient.AudioStop();
         dataClient.Dispose();
     }
     catch { }
 }
Пример #6
0
        /// <summary>
        /// Handles the Click event of the RadioButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void RadioButton_Click(object sender, RoutedEventArgs e)
        {
            // Reset everything
            if (_micClient != null)
            {
                _micClient.EndMicAndRecognition();
                _micClient.Dispose();
                _micClient = null;
            }

            if (_dataClient != null)
            {
                _dataClient.Dispose();
                _dataClient = null;
            }

            _logText.Text          = string.Empty;
            _startButton.IsEnabled = true;
            _radioGroup.IsEnabled  = true;
        }