So I'm trying voice recognition for C#, I'm using System.Speech.Recognition, and, I was searching around on the internet, trying out several pieces of code for some basic speech recognition, the best one I could find was this:
using System;
using System.Text;
using System.Windows.Forms;
using System.Speech.Recognition;
namespace SpeechRecognition
{
public partial class MainForm : Form
{
SpeechRecognitionEngine recognitionEngine;
public MainForm()
{
InitializeComponent();
Initialize();
}
private void Initialize()
{
recognitionEngine = new SpeechRecognitionEngine();
recognitionEngine.SetInputToDefaultAudioDevice();
recognitionEngine.SpeechRecognized += (s, args) =>
{
foreach (RecognizedWordUnit word in args.Result.Words)
{
// You can change the minimun confidence level here
if (word.Confidence > 0.8f)
freeTextBox.Text += word.Text + " ";
}
freeTextBox.Text += Environment.NewLine;
};
}
private void startButton_Click(object sender, EventArgs e)
{
try
{
recognitionEngine.UnloadAllGrammars();
recognitionEngine.LoadGrammar(new DictationGrammar());
RecognitionResult result = recognitionEngine.Recognize(new TimeSpan(0, 0, 20));
if (result != null)
{
foreach (RecognizedWordUnit word in result.Words)
{
freeTextBox.Text += word.Text + " ";
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void startAsyncButton_Click(object sender, EventArgs e)
{
recognitionEngine.UnloadAllGrammars();
recognitionEngine.LoadGrammar(new DictationGrammar());
recognitionEngine.RecognizeAsync(RecognizeMode.Multiple);
}
private void stopButton_Click(object sender, EventArgs e)
{
recognitionEngine.RecognizeAsyncStop();
}
private void startAsyncGrammarButton_Click(object sender, EventArgs e)
{
try
{
recognitionEngine.UnloadAllGrammars();
Grammar cg = CreateSampleGrammar();
recognitionEngine.LoadGrammar(cg);
recognitionEngine.RecognizeAsync(RecognizeMode.Multiple);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private Grammar CreateSampleGrammar()
{
Choices commandChoices = new Choices("Calculator", "Notepad", "Internet Explorer", "Paint");
GrammarBuilder grammarBuilder = new GrammarBuilder("Start");
grammarBuilder.Append(commandChoices);
Grammar g = new Grammar(grammarBuilder);
g.Name = "Available programs";
return g;
}
}
}
Now, I tried this, and some others, and they all resulted in the same error, a PlatformNotSupportedException, in the error it says: "There is no recogniser installed".
Is there any way around this? I'm running Windows 7 64 bits.