how to check if the user speak to microphone?

I want to check if the user speak to microphone (in c#). I searched easy way to do it and not found. I tried some libraries of audio but its not matched.

I need that the code will like:

if (user speak) speak=true;
else speak=false;

Is have easy way to do it?

This is a tough one, I’m afraid. As far as I know, there is no easy way to detect when the user speaks. There is no functionality in Unity for recording audio from a microphone, though plug-ins do exist if you have Unity Pro.

Even then, recording audio is just half the fun. You’d also need to figure out how to detect speech in the audio. If your app is used in quiet environments, I suppose you could simply trigger it when the recorded audio reaches above some threshold in dB, but if the app needs to work in noisy environments too, you’d need to analyze the signal somehow and see if it contains human speech.

I guess you already know that you can extend Unity’s functionality through plugins and there are a number of plugins already available that you may use to detect mic input. However, if you’re going to differentiate actual speech from any other auditory signal, then that’s a whole new deal altogether.

My team took weeks putting together a cross-platform speech recognition plugin for Unity and all I can tell you now is that there is no easy way of doing it, unfortunately. At least, not at the time I posted this answer.

Maybe when it becomes more popular, Unity might consider including an API for it. For now, we had to make one.

Here’s a sample of what we did. Don’t hesitate to drop us a line if you want to discuss further.