即使有安装的识别器,microsoft.speech中的无效参考

时间:2015-03-25 10:28:58

标签: c# unity3d speech-recognition

我正在尝试为我的Unity项目添加语音识别功能。乌龟演示工作正常;我可以用我的声音控制它。

在我自己的项目中,我试图搜索英语识别器:

string recognizerId = "SR_MS_en-US_Kinect_11.0";
RecognizerInfo ri = SpeechRecognitionEngine.InstalledRecognizers ().Where (r => r.Id == recognizerId).FirstOrDefault ();

导致无引用错误。

我也尝试搜索所有已安装的识别器:

foreach (RecognizerInfo recognizerinfo in SpeechRecognitionEngine.InstalledRecognizers()) 
    {
        string value;
        recognizerinfo.AdditionalInfo.TryGetValue("Kinect", out value);
        if("True".Equals(value, StringComparison.OrdinalIgnoreCase) && "en-US".Equals(recognizerinfo.Culture.Name, StringComparison.OrdinalIgnoreCase))
        {
            return recognizerinfo;
        }
    }

同样的错误。我检查了我的注册表,看起来很好:http://puu.sh/gOOyy/9a900bc335.png

这是我得到的完整错误:

NullReferenceException: Object reference not set to an instance of an object
Microsoft.Speech.Internal.ObjectTokens.RegistryDataKey.HKEYfromRegKey (Microsoft.Win32.RegistryKey regKey)
Microsoft.Speech.Internal.ObjectTokens.RegistryDataKey.RootHKEYFromRegPath (System.String rootPath)
Microsoft.Speech.Internal.ObjectTokens.RegistryDataKey.Open (System.String registryPath, Boolean fCreateIfNotExist)
Microsoft.Speech.Internal.ObjectTokens.ObjectTokenCategory.Create (System.String sCategoryId)
Microsoft.Speech.Recognition.SpeechRecognitionEngine.InstalledRecognizers ()
SpeechRecognition.GetKinectRecognizer () (at Assets/SpeechRecognition.cs:15)
SpeechRecognition.CreateSpeechRecognizer () (at Assets/SpeechRecognition.cs:31)
SpeechRecognition.InitializeKinect () (at Assets/SpeechRecognition.cs:76)
SpeechRecognition.Start () (at Assets/SpeechRecognition.cs:83)

我安装了Microsoft Serve语音平台运行时,Microsot语音平台SDK v11.0和Kinect for Windows语音识别语言包(en-US),不幸的是,我尝试重新安装无济于事。希望有人可以帮助我。

编辑:即使我只是测试一下:

System.Collections.ObjectModel.ReadOnlyCollection<RecognizerInfo> test = SpeechRecognitionEngine.InstalledRecognizers();

我得到了同样的错误。如果没有安装识别器,那么测试变量只是为空?

edit2:我刚刚在Visual Studio中测试了这段代码,它确实有效。所以出于某种原因,Unity并不想访问注册表?

0 个答案:

没有答案