public static async Task FredQ() { //Console.WriteLine("Please ask your question"); //await speech.SpeechToText(); string question = SpeechToText.text; // STT.FredHears(); if (question.Equals("Nothing recorded")) { NetCoreSample.Audio($"no_question.wav"); //tts.TextToWords(wolframText + "I didn't hear a question...").Wait(); // do nothing! } else { welcome = await VoiceIdentification.IdentVoice(); wolframText = KnowledgeBase.FredKB(question); // ProgramKB.FredKB(question); // apply 'cmd' variable here instead as it already contains the KB response if (wolframText == "") { await GetAnswer(question); if (wolframText == "") { NetCoreSample.Audio($"please_rephrase_question.wav"); //tts.TextToWords(welcome + "please rephrase your question").Wait(); } else { tts.TextToWords(welcome + " The answer is \n " + wolframText).Wait(); } } else { tts.TextToWords(welcome + " The answer is \n " + wolframText).Wait(); } } }
public static async Task Inquiry() { wolframText = ""; // reinitialize wolframText tio empty NetCoreSample.Audio(@"listening_beep.wav"); //await tts.TextToWords("I am listening..."); //STT.Hears(); speech.WordsToText(); string voice = SpeechToText.text.ToLower(); // STT.FredHears(); if (voice.Contains("what") && voice.Contains("see")) { //cmd = "Fred Sees"; FredVision.GetVision("describe").Wait(); tts.TextToWords(FredVision.FredSees()).Wait(); } else if (voice.Contains("who") && voice.Contains("see")) { //cmd = "Detect Face"; FredVision.GreetPerson(); } else if (voice.Contains("what") && voice.Contains("read")) { //cmd = "Fred Reads"; FredVision.GetVision("read").Wait(); tts.TextToWords(FredVision.FredReads()).Wait(); } else if (voice.Contains("light") && voice.Contains("on")) { //cmd = "Light On"; light.Value = PinValue.High; Console.WriteLine("Light On"); } else if (voice.Contains("light") && voice.Contains("off")) { //cmd = "Light Off"; light.Value = PinValue.Low; Console.WriteLine("Light Off"); } else { /*if(voice == "nothing recorded") * { * cmd = ""; * } * else * { * cmd = KnowledgeBase.FredKB(voice); * welcome = await VoiceIdentification.IdentVoice(); * }*/ await FredQ(); } /*cmd = cmd.Replace("\"", ""); * switch (cmd) * { * case "Fred Sees": * { * FredVision.GetVision("describe").Wait(); * TTS.Speak(FredVision.FredSees()).Wait(); * break; * } * case "Fred Reads": * { * FredVision.GetVision("read").Wait(); * TTS.Speak(FredVision.FredReads()).Wait(); * break; * } * case "Detect Face": * { * FredVision.GreetPerson(); * break; * } * case "Light On": * // run Light On code * break; * case "Light Off": * // run Light Off code * break; * default: * FredQ().Wait(); * break; * }*/ }