我试图将System.Speech.dll添加到我的Unity项目中,但出现System.BadImageFormatException。我正在使用64位Windows10。为x86_64设置了构建设置,而我正在使用的脚本运行时版本是“ .Net 4.x等效”。
我从“程序文件(x86)\参考程序集\ Microsoft \ Framework.NETFramework \ v4.6”中获得了该.dll。有趣的是,在MS Visual Studio中它实际上检测到了该dll,我可以编写:使用System.Speech,但Unity不想接受该.dll。我查看了不同的帖子,但没有任何帮助。任何帮助表示赞赏。
您不需要,System.Speech.dll
并且附带许多问题,因为它使用Mono。只需导入UnityEngine.Windows.Speech
名称空间就可以了。这要求Unity 5.4.0b2及更高版本可在Windows上运行。
你有不同类型的spech API,如DictationRecognizer
,GrammarRecognizer
,KeywordRecognizer
,PhraseRecognitionSystem
,和PhraseRecognizer
。该文档有许多有关如何使用每个示例的示例。
以下是KeywordRecognizer
doc中的示例:
[SerializeField]
private string[] m_Keywords;
private KeywordRecognizer m_Recognizer;
void Start()
{
m_Recognizer = new KeywordRecognizer(m_Keywords);
m_Recognizer.OnPhraseRecognized += OnPhraseRecognized;
m_Recognizer.Start();
}
private void OnPhraseRecognized(PhraseRecognizedEventArgs args)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat("{0} ({1}){2}", args.text, args.confidence, Environment.NewLine);
builder.AppendFormat("\tTimestamp: {0}{1}", args.phraseStartTime, Environment.NewLine);
builder.AppendFormat("\tDuration: {0} seconds{1}", args.phraseDuration.TotalSeconds, Environment.NewLine);
Debug.Log(builder.ToString());
}
这仅适用于Windows,因为您的目标是Window-64位。对于其他平台,请参阅本文。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句