How to add Speech Recognition to Unity project? [c

2019-01-08 01:46发布

问题:

I am presently working on a Augmented Reality project using Vuforia that uses Speech recognition to control the objects in Unity. I was just looking forward for a tutorial but i can't find one. Can you please guide me on where to start for this ! Your help is very much appreciated !

回答1:

Unity does not have this built in yet. They have been doing 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 to it if you find any problems.

As a side note, almost every OS has a Speech Recognition API. You easily make a plugin by wrapping all those API into a sing class in C# then use Unity's platform preprocessor directives to determine which one to call depending on which OS your game is running on.

Android:

SpeechRecognizer class.

iOS:

SFSpeechRecognizer class

MacOS:

NSSpeechRecognizer class

Windows:

SpeechRecognitionEngine class

Example:

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 
}

The free Speech-to-Text from Unity should have already solved your problem. The rest of the post is to let you know that you can make a plugin for this if there is a problem with the one from Unity.



回答2:

You can try Watson Unity SDK: https://github.com/watson-developer-cloud/unity-sdk^ in particular ExampleSpeechToText