Example #1
0
 public void StartRecording()
 {
     if (!Service.IsAuthorized())
     {
         Service.Authenticate(Key,
                              token => Service.Connect(),
                              exception => OnError.TryInvoke(exception.Message)
                              );
     }
     else
     {
         Service.Connect();
     }
 }
Example #2
0
        // ================================================
        // SOCKET EVENTS
        // ================================================
        void OnSocketError(object sender, ErrorEventArgs e)
        {
            var exception = e.Exception;

            if (exception != null)
            {
                OnError.TryInvoke(e.Exception);
            }
            else
            {
                OnError.TryInvoke(new Exception("Unknown socket error"));
            }

            Status = BingStatus.Authenticated;
        }
Example #3
0
        void Start()
        {
            // Setup service
            Service = new BingService {
                DoDebug = DoDebug
            };

            Service.OnError            += error => OnError.TryInvoke(error.Message);
            Service.OnSpeechHypothesis += hypothesis => OnHypothesis.TryInvoke(hypothesis.Text);
            Service.OnSpeechPhrase     += phrase => OnResult.TryInvoke(phrase.DisplayText);

            // Handle Mic
            m_Mic = Mic.Instance;
            m_Mic.StartRecording(16000, 20);
            m_Mic.OnSampleReady += (index, sample) => Service.Stream(sample.ToBytes());
        }