中文語音辨識 (ASUS A43S with Windows 7 x64)
1) Re-Install Speech SDK
1-1 Repair speeh platform runtime
http://www.microsoft.com/en-us/download/details.aspx?id=27225
1-2 Repair Speech SDK
http://www.microsoft.com/en-us/download/details.aspx?id=27226
1-3 Install speech runtime Language (zh-TW)
http://www.microsoft.com/en-us/download/details.aspx?id=27224#instructions
2) Add Ref :C:\Program Files\Microsoft SDKs\Speech\v11.0\Assembly\Microsoft.Speech.dll
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Speech.Recognition;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
// Create a new SpeechRecognitionEngine instance.
SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("zh-TW"));
// Create a simple grammar that recognizes "red", "green", or "blue".
Choices colors = new Choices();
colors.Add("向上");
colors.Add("向下");
colors.Add("左");
colors.Add("右");
colors.Add("前");
colors.Add("後");
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);
while (true)
{ }
}
static void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
Console.WriteLine(e.Result.Text);
}
}
}
沒有留言:
張貼留言