码迷,mamicode.com
首页 > 编程语言 > 详细

Unity使用Win10语音

时间:2018-01-06 14:23:50      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:下一步   null   windows   post   log   pos   void   需要   gpo   

1.    引入头文件

using UnityEngine.Windows.Speech;

2.    设置识别词

public string[] keywords = new string[] { "下一步", "上一步" };

3.    Start方法里面开启识别

   if (keywords != null)

    {

      recognizer = new KeywordRecognizer(keywords, confidence);

      recognizer.OnPhraseRecognized += Recognizer_OnPhraseRecognized;

      recognizer.Start();

  }

4.    结果函数写自己逻辑代码

 private void Recognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args)

    {

        word = args.text;

}

 

Args.text就是当前识别词结果,与设置好的识别词做比较即可

 

注意:需要开启语音服务和键盘输入建议

 

Unity使用Win10语音

标签:下一步   null   windows   post   log   pos   void   需要   gpo   

原文地址:https://www.cnblogs.com/dsh20134584/p/8213779.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!