public async Task FredQ() { wolframText = ""; await tts.TextToWords("I am listening..."); speech.WordsToText().Wait(); string voice = SpeechToText.text.ToLower(); if (voice == "nothing recorded") { cmd = ""; } else { cmd = KnowledgeBase.FredKB(voice); welcome = await VoiceIdentification.IdentVoice(); } cmd = cmd.Replace("\"", ""); switch (cmd) { case "Fred Sees": { tts.TextToWords("I see you Mark!").Wait(); break; } // run Fred Sees code case "Fred Reads": // run Fred Reads code break; case "Light On": // run Light On code break; case "Light Off": // run Light Off code break; default: AskFred().Wait(); break; } }
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(); } } }