windows自带语音识别


        private DictationRecognizer dictationRecognizer;
         void Awake()
        {
            dictationRecognizer = new DictationRecognizer(DictationTopicConstraint.Dictation);
            //订阅事件  
            dictationRecognizer.DictationResult += ListenSoundResult;
            dictationRecognizer.DictationComplete += ListenSoundComplete;
            dictationRecognizer.DictationError += ListenSoundError;
            dictationRecognizer.DictationHypothesis += ListenSound;
            //WarmUI.ClassOver = ClassOver;
        }
        private void ListenSound(string text)
        {
            Debug.Log(text);
        }

        private void ListenSoundError(string error, int hresult)
        {
            Debug.LogError(error);
            dictationRecognizer.Start();
        }

        private void ListenSoundComplete(DictationCompletionCause cause)
        {
            dictationRecognizer.Start();
        }

        private void ListenSoundResult(string text, ConfidenceLevel confidence)
        {
            if (text  == string.Empty)
                return;
            Debug.Log("识别内容:"+text);
            
        }

 

你可能感兴趣的:(代码)