1

My SAPI code for setting up the in proc recognition engine looks like this:

ISpeechRecoContext cpRecoCtx;
// create the recognition context
cpRecoCtx = new SpeechLib.SpInProcRecoContext();

((SpInProcRecoContext)cpRecoCtx).Recognition +=
    new _ISpeechRecoContextEvents_RecognitionEventHandler(RecoContext_Recognition);
/****** END: set up recognition context *****/

So how do I setup my audio input to default audio input in c#? I have found solutions in C++ but need one for C#.

1
  • 1
    The code you've supplied is incomplete. In particular, you need to specify a recognizer engine as well as an input source. Commented Jun 24, 2014 at 18:52

2 Answers 2

1

The default audio input object is SpMMAudioIn.

ISpeechRecoContext cpRecoCtx;
SpMMAudioIn audio = new SpMMAudioIn;
// set the audio input
cpRecoCtx.GetRecognizer.SetInput(audio);
Sign up to request clarification or add additional context in comments.

Comments

0

Eric, Your code does not work. First, there is no "GetRecognizer" Method. I've replaced that line with what should work. What version of SAPI are you referring to? I am using "Microsoft Speech Object libary 5.4". Next, you don't show how to set the audio input to a device as you mentioned. The following code should work, but it does not allow you to set the device ID, which had always worked in VB6. Trying to set the .DeviceID to anything throws an exception:

SpeechLib.ISpeechRecoContext cpRecoCtx;
cpRecoCtx = new SpeechLib.SpInProcRecoContext();
SpeechLib.SpMMAudioIn audio = new SpeechLib.SpMMAudioIn();
// set the audio input
// cpRecoCtx.GetRecognizer.SetInput(audio); <--- no such method
audio.DeviceId = 1;
cpRecoCtx.Recognizer.AudioInputStream = audio;

Surely, there has GOT to be a way to sent the input to a valid MMSYS (WaveInOpen) input stream.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.