I wrote an app in C# for speech recognition using System.Speech which works fine on Windows 7. However I'm after creating the same app that will work on windows 2003 (x86).
My programming environment: Windows 7 x64 Pro Visual Studio 2008
In order to develop this application in my programming environment I installed:
1.Microsoft Speech Platform - Server Runtime (Version 10.1) (x86)
2.Microsoft Speech Platform - Software Development Kit (SDK) (Version 10.1) (x86)
3.Microsoft Speech Platform - Server Runtime Languages (Version 10.1)
(here installed SR for en-GB)
In my program instead of System.Speech I used Microsoft.Speech.Recognition;
Pasted this code from SDK documentation:
using Microsoft.Speech.Recognition;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// Create a new SpeechRecognitionEngine instance.
sre = new SpeechRecognitionEngine();
// Create a simple grammar that recognizes “red”, “green”, or “blue”.
Choices colors = new Choices();
colors.Add("red");
colors.Add("green");
colors.Add("blue");
GrammarBuilder gb = new GrammarBuilder();
gb.Append(colors);
// Create the actual Grammar instance, and then load it into the speech recognizer.
Grammar g = new Grammar(gb);
sre.LoadGrammar(g);
// Register a handler for the SpeechRecognized event.
sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
sre.SetInputToDefaultAudioDevice();
sre.RecognizeAsync(RecognizeMode.Multiple);
}
// Simple handler for the SpeechRecognized event.
void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
MessageBox.Show(e.Result.Text);
}
SpeechRecognitionEngine sre;
}
}
I also set platform target to x86 in project properties. Code compiles but once I run or debug it recognition doesn't work. Any idea what am I missing?
You're creating a speech recognition engine without specifying an engine. Since you've installed the en-GB engine, you need to specify a cultureinfo (or a recognizerinfo):
sre = new SpeechRecognitionEngine(new CultureInfo("en-GB"));
来源:https://stackoverflow.com/questions/3600390/microsoft-speech-recognition-platform