Unity 尚未内置此功能。他们一直在做research https://labs.unity.com/article/speech-recognition-and-vr我们已经研究了很长时间,并且可能很快就会添加到 Unity 中。您可以从资产商店获取可用的语音转文本(免费)here https://www.assetstore.unity3d.com/en/#!/content/69399。它是开源的,您可以提供帮助贡献 https://bitbucket.org/Unity-Technologies/speech-to-text如果您发现任何问题,请及时联系我们。
顺便说一句,几乎每个操作系统都有一个语音识别 API。您可以通过将所有这些 API 包装到 C# 中的一个类中来轻松制作一个插件,然后使用Unity 的平台预处理器指令 https://docs.unity3d.com/Manual/PlatformDependentCompilation.html根据您的游戏运行的操作系统来确定调用哪一个。
Android:
语音识别器 https://developer.android.com/reference/android/speech/SpeechRecognizer.html class.
看到这个项目https://github.com/gsssrao/UnityAndroidSpeechRecognition https://github.com/gsssrao/UnityAndroidSpeechRecognition
iOS:
SF语音识别器 https://developer.apple.com/reference/speech/sfspeechrecognizer class
MacOS:
NSS语音识别器 https://developer.apple.com/reference/appkit/nsspeechrecognizer class
Windows:
语音识别引擎 https://msdn.microsoft.com/en-us/library/system.speech.recognition.speechrecognitionengine(v=vs.110).aspx class
看到这个项目https://github.com/LightBuzz/Speech-Recognition-Unity https://github.com/LightBuzz/Speech-Recognition-Unity
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
}
免费语音转文本 https://www.assetstore.unity3d.com/en/#!/content/69399遗憾的是,Unity 已停止使用,如链接中所述。