嘗試使用SpeechRecognitionEngine
代替SpeechRecognizer
下面是一個例子:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Recognition;
namespace speectest
{
class Program
{
static void Main(string[] args)
{
SpeechRecognitionEngine engine = new SpeechRecognitionEngine();
GrammarBuilder grandma = new GrammarBuilder();
engine.SetInputToDefaultAudioDevice();
grandma.AppendDictation();
engine.LoadGrammar(new Grammar(grandma));
engine.RecognizeCompleted += new EventHandler<RecognizeCompletedEventArgs>(engine_RecognizeCompleted);
engine.RecognizeAsync();
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
}
static void engine_RecognizeCompleted(object sender, RecognizeCompletedEventArgs e)
{
Console.WriteLine(e.Result.Text);
}
}
}
我們在[SO]上使用標籤來組織問題。您無需在標題中添加「Windows 7上的語音識別C#Visual Studio 2010」。 –