我试图将System.Speech.dll添加到我的Unity项目,但我得到System.BadImageFormatException . 我使用的是64位Windows 10.构建设置是为x86_64设置的,我使用的脚本运行时版本是“.Net 4.x等效” .
那个.dll我从“Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.6”中得到它 . 有趣的是在MS Visual Studio中它实际上检测到dll和我可以写:使用System.Speech但Unity不想接受.dll . 我看了不同的帖子,但没有任何对我有用 . 任何帮助赞赏 .
1 回答
你不需要
System.Speech.dll
,它有很多问题,因为它使用Mono . 只需导入UnityEngine.Windows.Speech
命名空间就可以了 . 这需要Unity 5.4.0b2及更高版本才能在Windows上运行 .您有不同类型的spech API,例如DictationRecognizer,GrammarRecognizer,KeywordRecognizer,PhraseRecognitionSystem和PhraseRecognizer . 该文档有很多关于如何使用每个例子的例子 .
以下是doc中KeywordRecognizer的示例:
这仅适用于Windows,因为您的目标是Window-64位 . 对于其他平台,请参阅this post .