나는 내 C# 프로젝트에서이 코드를 가지고 :이 음성 인식 wicked 버그를 고치는 방법?
public void startRecognition(string pName)
{
presentationName = pName;
if (WaveNative.waveInGetNumDevs() > 0)
{
string grammar = System.Environment.GetEnvironmentVariable("PUBLIC") + "\\SoundLog\\Presentations\\" + presentationName + "\\SpeechRecognition\\soundlog.cfg";
if (File.Exists(grammar))
{
File.Delete(grammar);
}
executeCommand();
/// Create an instance of SpSharedRecoContextClass which will be used
/// to interface with the incoming audio stream
recContext = new SpSharedRecoContextClass();
// Create the grammar object
recContext.CreateGrammar(1, out recGrammar);
//recContext.CreateGrammar(2, out recGrammar2);
// Set up dictation mode
//recGrammar2.SetDictationState(SpeechLib.SPRULESTATE.SPRS_ACTIVE);
//recGrammar2.SetGrammarState(SPGRAMMARSTATE.SPGS_ENABLED);
// Set appropriate grammar mode
if (File.Exists(grammar))
{
recGrammar.LoadCmdFromFile(grammar, SPLOADOPTIONS.SPLO_STATIC);
//recGrammar.SetDictationState(SpeechLib.SPRULESTATE.SPRS_INACTIVE);
recGrammar.SetGrammarState(SPGRAMMARSTATE.SPGS_ENABLED);
recGrammar.SetRuleIdState(0, SPRULESTATE.SPRS_ACTIVE);
}
/// Bind a callback to the recognition event which will be invoked
/// When a dictated phrase has been recognised.
recContext.Recognition += new _ISpeechRecoContextEvents_RecognitionEventHandler(handleRecognition);
// System.Windows.Forms.MessageBox.Show(recContext.ToString());
// gramática compilada
}
}
private static void handleRecognition(int StreamNumber,
object StreamPosition,
SpeechLib.SpeechRecognitionType RecognitionType,
SpeechLib.ISpeechRecoResult Result)
{
string temp = Result.PhraseInfo.GetText(0, -1, true);
_recognizedText = "";
// System.Windows.Forms.MessageBox.Show(temp);
// System.Windows.Forms.MessageBox.Show(recognizedWords.Count.ToString());
foreach (string word in recognizedWords)
{
if (temp.Contains(word))
{
// System.Windows.Forms.MessageBox.Show("yes");
_recognizedText = word;
}
}
}
이 코드는 내가 다른 응용 프로그램에서 사용하는 DLL을 생성합니다.
악의적 인 버그 : - 다른 응용 프로그램의 실행 시작 부분에서 startRecognition 메서드를 실행할 때이 코드는 매우 잘 작동합니다. 하지만 처음부터 약간의 시간이 지나면이 코드는 작동하지만 handleRecognition 메서드는 호출되지 않습니다. 단어가 Microsoft 음성 인식 응용 프로그램에 나타나기 때문에 인식되지만 핸들러 메서드는 호출되지 않습니다.
이 코드의 문제점을 알고 계십니까?
참고 :이 프로젝트에는 항상 실행중인 일부 코드가 있습니다. 그게 문제일까요? 다른 코드가 실행되고 있기 때문에이 코드를 실행할 수 없습니다.
그것은 컴파일러가 분노와 당신의 평균 트릭을 재생하고 모든 의견 수를했다 : 당신이 핸들러는 가상이 아닌 정적 만드는 시도하면 그냥 궁금 P –
를? – code4life
나중에 가상의 것을 시도 할 것입니다. –