Microsoft Speech Recognition Platform

Artur Kędzior picture Artur Kędzior · Aug 30, 2010 · Viewed 13.1k times · Source

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)

http://www.microsoft.com/downloads/details.aspx?FamilyID=674356C4-E742-4855-B3CC-FC4D5522C449&displaylang=en&displaylang=en

2.Microsoft Speech Platform - Software Development Kit (SDK) (Version 10.1) (x86)

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=4d36908b-3264-49ef-b154-f23bf7f44ef4

3.Microsoft Speech Platform - Server Runtime Languages (Version 10.1)

(here installed SR for en-GB)

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=f704cd64-1dbf-47a7-ba49-27c5843a12d5

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?

Answer

Eric Brown picture Eric Brown · Aug 31, 2010

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"));