本文介绍了通过c#中的语音搜索网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我有一个问题......当我说搜索+我想搜索的东西(通过语音)时,我怎么能搜索一些东西,(也许是谷歌?)。请帮助我,我完整卡住:P,到目前为止查看我的代码...
Hello guys,i have a question...How can i search something when i say "search for" + the thing i wanna search (via speech),(maybe in google?).Please help me,i am completly stuck :P,look my code so far...
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; using System.Speech.Recognition; using System.Speech.Synthesis; using System.IO; namespace JARVIStest { public partial class Form1 : Form { SpeechRecognitionEngine _recognizer = new SpeechRecognitionEngine(); SpeechSynthesizer JARVIS = new SpeechSynthesizer(); string QEvent; int count = 1; Random rnd = new Random(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { _recognizer.SetInputToDefaultAudioDevice(); _recognizer.LoadGrammar(new Grammar(new GrammarBuilder(new Choices(File.ReadAllLines(@"C:\Users\Cpyros\Desktop\lefteris\Commands.txt"))))); _recognizer.SpeechRecognized += new EventHandler<speechrecognizedeventargs>(_recognizer_SpeechRecognized); _recognizer.RecognizeAsync(RecognizeMode.Multiple); } void _recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { int ranNum = rnd.Next(1, 10); string speech = e.Result.Text; switch (speech) { //GREETINGS case "hello": case "hello jarvis": if (ranNum < 6) { JARVIS.Speak("Hello sir"); } else if (ranNum > 5) { JARVIS.Speak("Hi"); } break; case "goodbye": case "goodbye jarvis": case "close": case "close jarvis": JARVIS.Speak("Until next time"); Close(); break; case "jarvis": if (ranNum < 5) { QEvent = ""; JARVIS.Speak("Yes sir"); } else if (ranNum > 4) { QEvent = ""; JARVIS.Speak("Yes?"); } break;这里我想添加一个案例搜索或搜索谷歌
here i wanna add a case "search for" or "search google"
推荐答案developers.google。 com / image-search / v1 / devguide [ ^ 阅读本文pLease developers.google/image-search/v1/devguide[^] Read This Article pLease
更多推荐
通过c#中的语音搜索网络
发布评论