Creating a KeywordRecognizer makes Unity crash

Hi !

I am currently trying to develop a project using both Speech Recognition and the Oculus Rift DK1.

I developed the speech recognition part by using the KeywordRecognizer from Unity Scripting API (Note : I’m working on Windows 10). It worked well and I was able to detect words and do an action depending on the recognized word.

After that, I installed the Oculus Runtime for Windows V0.8.0.0-beta which also required me to install an NVIDIA graphic driver with a version above 358.xx, so I installed the latest version which was 369.09.

Later, when I tried launching my game which already used a KeywordRecognizer, Unity crashed. By crash I mean it did not even freeze for 1 second but I immediately had the message “Unity Editor has stopped working”. I tried creating a whole new project with only one script (the one given in the Unity Documentation) :

[SerializeField]
private string[] m_Keywords;

private KeywordRecognizer m_Recognizer;

		void Start()
		{
			m_Recognizer = new KeywordRecognizer(m_Keywords);
			m_Recognizer.OnPhraseRecognized += OnPhraseRecognized;
			m_Recognizer.Start();
		}

But it still crashes everytime I launch the game in the Editor. I tried debugging it with Visual Studio, and the problem comes from the following line :

m_Recognizer = new KeywordRecognizer(m_Keywords);

When Unity crashes, I can debug it and have the following error :

Unhandled exception at 0x77485E93 (ntdll.dll) in Unity.exe: 0xC0000005: Access violation writing location 0x00000040.

I am sure the problem is not coming from the string table since I tried several examples given by Unity Documentation or Microsoft Developer Network.

Since it is an access violation error, I thought maybe another process is trying to access the same location in memory at the same time. I uninstalled the Oculus Runtime and driver, and I also uninstalled the NVIDIA driver. It still didn’t work. I uninstalled and reinstalled Unity several times, tried launching my script in different versions of Unity (5.4.0f3 - 32 and 64 bits, and 5.4.0b15 - 32 and 64 bits), but nothing works.

I compiled my project and tried launching the .exe file, and the executable also crashed. Then, I put the exact same .exe file on a Surface Pro 3 running under Windows 10, and it worked perfectly.

At this point, since I had no restore points on Windows, I decided to reset my PC (but still keep my files). It still does not work … The last thing I tried was replacing the Windows.Media.Speech.dll (in C:\Windows\System32) on my computer by the one I found on the Surface Pro, but it didn’t help.

I am running out of ideas and I would like to know if anyone already faced this problem or has an idea of something I could try to “repair” Unity, before I reset my PC completely.

EDIT : I tried using a DictationRecognizer instead of a KeywordRecognizer, and the problem is still the same.

Okay.

I’m not sure why, but now it works. Here’s what happened :

I uninstalled VS 2015 and installed VS Express 2013, and I uninstalled/reinstalled all the VC Redistributable (2010, 2012, 2013, 2015). After that, Unity did not crash anymore but when I wanted to use a KeywordRecognizer it would give me the error “Speech recognition is not available on this machine” (or something like that).

I did nothing else and then today there was a major Windows 10 Update, and now speech recognition works properly. So I guess a dll was corrupted during a previous Update or when I installed new drivers …

Problem solved. :slight_smile: