using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Speech.Recognition;
using System.Globalization;
using Microsoft.Speech.Synthesis;
using Microsoft.Speech.AudioFormat;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new CultureInfo("en-US"));
public Form1()
{
InitializeComponent();
}
public void LoadFile()
{
try
{
sre.SetInputToDefaultAudioDevice();
String[] comands = { "yes" };
sre.LoadGrammar(new Grammar(new GrammarBuilder(new Choices(comands))));
sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(rec);
sre.RecognizeAsync(RecognizeMode.Multiple);
}
catch (Exception ex)
{
MessageBox.Show("Erro:" + ex.Message);
}
}
private void Form1_Load(object sender, EventArgs e)
{
LoadFile();
}
private void rec(object s, SpeechRecognizedEventArgs e)
{
label1.Text = e.Result.Text;
}
}
}
Ele não esta reconhecendo quando eu falo "yes".
Ele fala também que: "Error: The language for grammar does not match the language of the speech recognizer."