- Home /
Speech Recognition Unity Pro
Hey guys,
I'm wanting to implement speech recognition into my unity game using the .NET library System.Speech. I understand that this libary isn't (or at least doesn't seem to be) supported in the current version of Unity (even when the reference is added). My question is, if i was to purchase Unity Pro which allows me to add native plug-ins (.dll files), would I be able to add the System.Speech.dll file to my Unity Pro application??
Has anyone attempted this previously??
Answer by CHPedersen · Dec 08, 2011 at 01:24 PM
As I understand plugins, they give you access to good ol' P/Invoke. P/Invoke is when you call native code in a DLL-file by using the "extern"-keyword to declare in your managed code that the implementation of a function is to be found in a native library and not in the same assembly. This enables the runtime to load the functions in the DLL file you link to, and to mix memory access to both the managed heap and whatever the DLL uses (by way of marshalling, I believe).
Unfortunately for you, that's not what you want to do. Plugins and P/Invoke is strictly for native code, but just because something is a DLL file does not make it native code. System.Speech is not native code, it's a class library written in .Net. You can't call its functions or instantiate its objects with plugins, unfortunately. System.Speech looks like a relatively new addition to the .Net framework, so chances are the horribly outdated Mono version used by Unity (Unity Technologies: update it already!) doesn't cover that particular namespace.
Answer by Bunny83 · Dec 08, 2011 at 02:41 PM
Usually you can add any pure .NET / Mono dll to your project as an asset. Just place the dll somewhere in you asset folder (not in the plugins folder) and you should be able to use it, as long as it's own dependencies are available.
I think he has tried this already, and come up with the conclusion that it wasn't supported, likely because it was built with .Net components not included in Unity's current version of $$anonymous$$ono.
I've tried adding the library to the "references" folder in the compiler, however i haven't tried adding it in my asset folder. Do you think this might make a difference??
Yes, it would make a difference ;) The references of your solution / project aren't used by Unity. Unity calls the compiler itself and it only can use assemblies that are directly supported / known to Unity and those that belong to your project which includes all assemblies Unity creates itself and all assemblies that are within the asset folder.
However, like already said, if your assembly belongs to something that isn't supported by Unity's mono version it won't work.
Thank you so much ... this worked ! I have been trying since yesterday to work this out.