本文介绍了从语音识别器中调用按钮对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows Vista中的WPF应用程序处理语音识别项目.我想先调用语音识别引擎,然后再调用我的应用程序窗口.但是正好相反.首先,我的应用程序窗口运行&然后在单击按钮后,语音引擎启动.以下是我尝试作为演示的代码.

I am working over a Speech Recognition project using WPF application in Windows Vista. I want to call the Speech recognition engine and then my application window. But exactly opposite is going on. First my application window runs & then after clicking a button the speech engine starts. Following is the code that I have tried as a demo.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Speech;
using System.Speech.Recognition; 
namespace WpfApplication1
{
// protected SpeechRecognizer spRecognizer;
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show(((Button)sender).ToString());
SpeechRecognizer spRecognizer = new SpeechRecognizer();
spRecognizer.Enabled=true;
spRecognizer.SpeechRecognized+=new EventHandler<SpeechRecognizedEventArgs>(spRecognizer_SpeechRecognized);
} 
void spRecognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
throw new NotImplementedException();
string str=e.Result.Text;
MessageBox.Show(str);
}
}
}

请提出一些建议.

推荐答案


这篇关于从语音识别器中调用按钮对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 07:54