Youtube、谷歌、Facebook语音搜索(语音识别C#)
本文关键字:语音识别 语音 谷歌 Facebook Youtube 搜索 | 更新日期: 2023-09-27 18:09:49
有人能告诉我如何解决这个问题吗?它只搜索我在Commands.txt._recognizer.LoadGrammar(new Grammar(new GrammarBuilder(new Choices(System.IO.File.ReadAllLines(@"C:'Commands.txt")))));
中写的关键词。当它问我你想搜索什么时?我说"香蕉",但香蕉没有包含在Commands.txt中,所以它不会做任何事情。
嗯。我希望它是这样的。当你说我想搜索什么(它会问你想搜索什么(,那么你想说什么(水果、酒店、人、动物——所有你会说的词(。它应该出现在谷歌搜索栏上
if (speech == "I WANT TO SEARCH SOMETHING")
{
QEvent = speech;
ENZO.SpeakAsync("what do you want to search");
speech = string.Empty;
}
else if (speech != string.Empty && QEvent == "I WANT TO SEARCH SOMETHING")
{
Process.Start("http://google.com/search?q=" + speech);
QEvent = string.Empty;
if (ranNum < 6) { ENZO.SpeakAsync("Alright, I am searching " + speech + " in google"); }
else if (ranNum > 5) { ENZO.SpeakAsync("ok sir, I am searching " + speech); }
speech = string.Empty;
}
我也试过下面的代码,但在说了一些东西之后,它只打开了谷歌,但没有搜索到任何东西。
if (speech.ToLower().Contains("search for")) // See if the string contains the 'search for' string.
{
string query = speech.Replace("search for", ""); // Remove the 'search for' text.
// Old code (does not make the text fully URL safe)
// query = query.Replace(' ', '+');
query = System.Web.HttpUtility.UrlEncode(query);
string url = "https://www.google.com.au/search?q=" + query;
System.Diagnostics.Process.Start(url);
}
if (speech.ToLower().Contains("search for")) // See if the string contains the 'search for' string.
{
string query = speech.Replace("search for", ""); // Remove the 'search for' text.
// Old code (does not make the text fully URL safe)
// query = query.Replace(' ', '+');
query = System.Web.HttpUtility.UrlEncode(query);
string url = "https://www.google.com.au/search?q=" + query;
System.Diagnostics.Process.Start(url);
}