Search code examples
c#audiovoice-recognition

SpeechRecognitionEngine.AudioLevel does not change


I've been working with the Kinect and Voice Recognition, and I'm noticing that I can't get the AudioLevel member to change from my SpeechRecognitionEngine object.

I am successful in getting the commands to be recognized, so I know that the kinect is presenting my application with sound. I've tried subscribing to the AudioLevelUpdated event and reading the AudioLevel directly, but the event doesn't fire and the AudioLevel is always 0.

Is there anything special I need to do activate the AudioLevel?


Solution

  • I remember having the same problem in the past. In my search for a solution I found that it could have several reasons but I haven't really been able (have not had the time) to pinpoint the problem for my case yet. I will still list some reasons I have found.

    • It is not using SAPI 5.3 and therefore will always return zero because SAPI 5.1 doesn't support this.
    • It has been reported in several forums that it may be a .NET v4 runtime problem.
    • The AudioLevel is based on AudioStatus.dwAudioLevel which may return 0 for a reason.

    A workaround which has been suggested on MSDN(by IanPeters) and worked ok for me was to extract the sample audio from the Recognized audio, use RecognizedAudio.WriteToWaveStream() and then take the average of the absolute value of the audio. This will give you an estimate and could be sufficient for your situation.

    The original post of IanPeters is located on msdn (SpeechRecognitionEngine.AudioLevel)