private void Start()
    {
        m_DictationRecognizer = new DictationRecognizer();
        m_DictationRecognizer.DictationResult += (text, confidence) =>
        {
            OnSpeechResult?.Invoke(this, text);
        };

        m_DictationRecognizer.DictationHypothesis += (text) =>
        {
            OnSpeechHypothesis?.Invoke(this, text);
        };

        m_DictationRecognizer.DictationComplete += (completionCause) =>
        {
            if (completionCause != DictationCompletionCause.Complete)
            {
                Debug.LogErrorFormat("Dictation completed unsuccessfully: {0}.", completionCause);
            }
        };

        m_DictationRecognizer.DictationError += (error, hresult) =>
        {
            Debug.LogErrorFormat("Dictation error: {0}; HResult = {1}.", error, hresult);
        };

        m_DictationRecognizer.Start();
    }
Exemple #2
0
        void OnSocketMessage(object sender, MessageEventArgs e)
        {
            var parser  = new MessageParser(e.Data);
            var message = parser.GetObject();

            // All events are fired from the main thread
            Dispatcher.Enqueue(() => {
                OnGetMessage.TryInvoke(message);
                switch (parser.Path.ToLower())
                {
                case "turn.start":
                    OnTurnStart.TryInvoke(message as TurnStartMessage);
                    break;

                case "turn.end":
                    m_Socket.Send(BingUtils.TurnEndAcknowledgement());
                    m_Buffer = new byte[0];
                    OnTurnEnd.TryInvoke(message as TurnEndMessage);

                    Status = BingStatus.Disconnecting;
                    m_Socket.CloseAsync(() => {
                        Connect();
                    });
                    break;

                case "speech.enddetected":
                    OnSpeechEndDetected.TryInvoke(message as SpeechEndDetectedMessage);
                    break;

                case "speech.phrase":
                    OnSpeechPhrase.TryInvoke(message as SpeechPhraseMessage);
                    break;

                case "speech.hypothesis":
                    OnSpeechHypothesis.TryInvoke(message as SpeechHypothesisMessage);
                    break;

                case "speech.startdetected":
                    OnSpeechStartDetected.TryInvoke(message as SpeechStartDetectedMessage);
                    break;

                case "speech.fragment":
                    OnSpeechFragment.TryInvoke(message as SpeechFragmentMessage);
                    break;
                }
            });
        }