public static async Task GetAnswer(string search) { client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue ("applicationException/json")); // grab 20 vids HttpResponseMessage response = await client.GetAsync($"https://api.wolframalpha.com/v1/result?i= {search}&appid={appKey}"); if (response.IsSuccessStatusCode) { test = true; string Data = await response.Content.ReadAsStringAsync(); wolframText = Data.Split(". ")[0]; //Console.WriteLine(wolframText); if (wolframText.Length < 10) { AskQuestion(search).Wait(); } else { Console.WriteLine(wolframText); } //Console.ReadLine(); } else { ProgramTTS.TTSEntry("please rephrase your question"); test = false; cmd = "Ask"; } }
public static async Task FredQnA() { Console.WriteLine("Please ask your question"); await speech.SpeechToText(); string question = ProgramRestSTT.text; if (question.Equals("*")) { // do nothing! } else { wolframText = ProgramKB.FredKB(question); if (wolframText == "") { await GetAnswer(question); ProgramTTS.TTSEntry(wolframText); } else { ProgramTTS.TTSEntry(wolframText); } } }