Я пишу плагин (файл dll) с помощью/clr и пытаюсь реализовать распознавание речи с помощью .NET. Но когда я запустил его, у меня возникла ошибка времени выполнения: «Значение не входит в ожидаемый диапазон», что означает это сообщение?Что означает «Значение не входит в ожидаемый диапазон» означает ошибку во время выполнения?
public ref class Dialog : public System::Windows::Forms::Form
{
public: SpeechRecognitionEngine^ sre;
private: System::Void btnSpeak_Click(System::Object^ sender, System::EventArgs^ e)
{
Initialize();
}
protected: void Initialize()
{
//create the recognition engine
sre = gcnew SpeechRecognitionEngine();
//set our recognition engine to use the default audio device
sre->SetInputToDefaultAudioDevice();
//create a new GrammarBuilder to specify which commands we want to use
GrammarBuilder^ grammarBuilder = gcnew GrammarBuilder();
//append all the choices we want for commands.
//we want to be able to move, stop, quit the game, and check for the cake.
grammarBuilder->Append(gcnew Choices("play", "stop"));
//create the Grammar from th GrammarBuilder
Grammar^ customGrammar = gcnew Grammar(grammarBuilder);
//unload any grammars from the recognition engine
sre->UnloadAllGrammars();
//load our new Grammar
sre->LoadGrammar(customGrammar);
//add an event handler so we get events whenever the engine recognizes spoken commands
sre->SpeechRecognized += gcnew EventHandler<SpeechRecognizedEventArgs^> (this, &Dialog::sre_SpeechRecognized);
//set the recognition engine to keep running after recognizing a command.
//if we had used RecognizeMode.Single, the engine would quite listening after
//the first recognized command.
sre->RecognizeAsync(RecognizeMode::Multiple);
//this->init();
}
void sre_SpeechRecognized(Object^ sender, SpeechRecognizedEventArgs^ e)
{
//simple check to see what the result of the recognition was
if (e->Result->Text == "play")
{
MessageBox(plugin.hwndParent, L"play", 0, 0);
}
if (e->Result->Text == "stop")
{
MessageBox(plugin.hwndParent, L"stop", 0, 0);
}
}
};
Что такое стек вызовов исключения? – SLaks
Отладчики - ваш друг. Загрузите его и узнайте, какая строка вызывает у вас проблему. не зная, что такое ваш вход, и как вы его передаете, или какой ваш точный результат трудно помочь –
@SLacks: Извините, я не понимаю ваш вопрос, я новичок в этом программировании. – manuel