public JsonResult SpeakerIdentification(string data)
 {
     try
     {
         VoiceIdentification vi = new VoiceIdentification(); //Creating object for VoiceIdentification Class
         vi.SpeakerIdentification(data);
         if (vi.Error == "")                                 // Returning Result as a json if no error occur
         {
             return(Json(new { Result = vi.Result, Error = "" }));
         }
         return(Json(new { Result = "", Error = vi.Error })); // Returning  Error Result as a json if any error occur
     }
     catch (Exception e)                                      // handling runtime errors and returning error as Json
     {
         return(Json(new { Result = "", Error = e.Message }));
     }
 }
Пример #2
0
        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;
            }
        }
Пример #3
0
        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();
                }
            }
        }