Reputation: 21
Here is my code, I am not familiar with SpeechLib Dll i have referred one website and i just tried.
I have already done speech to text application using System.Speech namespace. But there i couldn't get the 100% accuracy, so only i am just trying the possibilities available.
static void Main(string[] args)
{
wavRecoContext = new SpInProcRecoContext();
((SpInProcRecoContext)wavRecoContext).Recognition += new _ISpeechRecoContextEvents_RecognitionEventHandler(Program_Recognition);
((SpInProcRecoContext)wavRecoContext).Hypothesis += new _ISpeechRecoContextEvents_HypothesisEventHandler(Program_Hypothesis);
((SpInProcRecoContext)wavRecoContext).EndStream += new _ISpeechRecoContextEvents_EndStreamEventHandler(Program_EndStream);
grammar = wavRecoContext.CreateGrammar(0);
grammar.DictationLoad("", SpeechLoadOption.SLOStatic);
inputFileStream = new SpFileStream();
inputFileStream.Open("aboutus.wav", SpeechStreamFileMode.SSFMOpenForRead, false);
wavRecoContext.Recognizer.AudioInputStream = inputFileStream;
grammar.DictationSetState(SpeechRuleState.SGDSActive);
Console.ReadKey();
}
static void Program_Hypothesis(int StreamNumber, object StreamPosition, ISpeechRecoResult Result)
{
throw new NotImplementedException();
}
static void Program_EndStream(int StreamNumber, object StreamPosition, bool StreamReleased)
{
grammar.DictationSetState(SpeechRuleState.SGDSInactive);
}
static void Program_Recognition(int StreamNumber, object StreamPosition, SpeechRecognitionType RecognitionType, ISpeechRecoResult Result)
{
Console.WriteLine(Result.PhraseInfo.GetText(0, -1, true));
}
}
I couldn't able figure out what mistake i made here. If anybody had experience on this issue please give me solution.
Upvotes: 1
Views: 1456
Reputation: 13942
You're not selecting an SR engine. In-process reco contexts need to specify both an audio source and a recognition engine.
I have some C++ code to do this, but I haven't translated it to C#/SpeechLib.
Upvotes: 1