我真的很喜欢微软最新的语音识别(和 SpeechSynthesis)产品。
http://msdn.microsoft.com/en-us/library/ms554855.aspx
http://estellasays.blogspot.com/2009/04/speech-recognition-in-cnet.html
但是,我觉得在使用语法时我有些受限。
不要误会我的意思,语法非常适合准确地告诉语音识别要注意哪些单词/短语,但是如果我想让它识别我没有提醒它的东西怎么办?或者我想解析一个半预先确定的命令名称和半随机单词的短语?
例如..
场景 A - 我说“Google [Oil Spill]”,我希望它打开 Google 的搜索结果,括号中的术语可以是任何内容。
场景 B - 我说“定位 [曼彻斯特]”,我希望它在 Google 地图或其他任何非预先确定的地方搜索曼彻斯特
我想让它知道“Google”和“Locate”是命令,它之后是参数(并且可以是任何东西)。
问题:有谁知道如何混合使用预先确定的语法(语音识别应该识别的单词)和不在其预先确定的语法中的单词?
代码片段..
using System.Speech.Recognition;
...
...
SpeechRecognizer rec = new SpeechRecognizer();
rec.SpeechRecognized += rec_SpeechRecognized;
var c = new Choices();
c.Add("search");
var gb = new GrammarBuilder(c);
var g = new Grammar(gb);
rec.LoadGrammar(g);
rec.Enabled = true;
...
...
void rec_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
if (e.Result.Text == "search")
{
string query = "How can I get a word not defined in Grammar recognised and passed into here!";
launchGoogle(query);
}
}
...
...
private void launchGoogle(string term)
{
Process.Start("IEXPLORE", "google.com?q=" + term);
}