如何在Unity项目中添加语音识别?

Kan*_*gam 5 c# speech-recognition unity-game-engine augmented-reality vuforia

我目前正在使用Vuforia进行增强现实项目,该项目使用语音识别来控制Unity中的对象.我只是在寻找一个示例工作代码.

Pro*_*mer 17

Unity尚未内置此功能.他们已经对它进行了很长时间的研究,很快就会将其添加到Unity中.您可以在此处从Assets商店获取有效的Speech-to-Text(免费).它是开源的,你可以帮助促进,如果你发现任何问题吧.

作为旁注,几乎每个操作系统都有语音识别API.您可以通过将所有这些API包装到C#中的单元类中来轻松制作插件,然后使用Unity的平台预处理程序指令来确定根据您的游戏运行的操作系统调用哪一个.

Android:

SpeechRecognizer类.

看到这个项目https://github.com/gsssrao/UnityAndroidSpeechRecognition

iOS:

SFSpeechRecognizer

MacOS:

NSSpeechRecognizer

Windows:

SpeechRecognitionEngine

看到这个项目https://github.com/LightBuzz/Speech-Recognition-Unity

例:

class CrazySpeechRecognition
{
  #if UNITY_ANDROID  
    Use SpeechRecognizer class
  #endif

  #if UNITY_IOS
    Use SFSpeechRecognizer class
  #endif

  #if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
    Use NSSpeechRecognizer class
  #endif

  #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
    Use SpeechRecognitionEngine class
  #endif 
}
Run Code Online (Sandbox Code Playgroud)

正如链接中所述,Unity 的免费语音转文本已被遗忘.