如何将语音识别添加到 Unity 项目?

How to add Speech Recognition to Unity project?

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

Unity 还没有内置这个。如果您发现任何问题,他们一直在对其进行 research on it for a long time and this will likely be added into Unity very soon. You can get the working Speech-to-Text(free) from the Assets store here. It is open source and you can help contribute

附带说明一下,几乎每个 OS 都有语音识别 API。您可以通过将所有这些 API 包装到 C# 中的单个 class 中轻松制作一个插件,然后使用 Unity's platform preprocessor directives 来确定调用哪个 OS 您的游戏 运行上。

Android:

SpeechRecognizer class.

查看此项目https://github.com/gsssrao/UnityAndroidSpeechRecognition

iOS:

SFSpeechRecognizer class

MacOS:

NSSpeechRecognizer class

Windows:

SpeechRecognitionEngine class

查看此项目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 
}

遗憾的是,Unity 的免费 Speech-to-Text 已停产,如 link 中所述。

您可以尝试 Watson Unity SDK:https://github.com/watson-developer-cloud/unity-sdk^ 特别是 ExampleSpeechToText