public async Task <string> InputTextAndReturnSoundFile(TextInput input)
        {
            var text = input.Text;
            var textToSpeechService = new TextToSpeechService();
            var uri = await textToSpeechService.GenerateAudioSpeech(text);

            return(uri);
        }
Esempio n. 2
0
        public async Task <TextAndAudioWrapper> InputQuestionAndReturnAnswer(TextInput textInput)
        {
            var luisService = new LuisService();
            var wrapper     = new TextAndAudioWrapper();
            var question    = textInput.Text;

            var generalKB = new QnAMakerService(_qnaHostName,
                                                "d282ad63-9701-4548-afac-a421f0ec43ed", _endPointKey);

            var groupKB = new QnAMakerService(_qnaHostName,
                                              "b51f7e68-706b-42e4-8b31-0dd34d392a54", _endPointKey);

            var postKB = new QnAMakerService(_qnaHostName,
                                             "92e0fe0c-8826-4e60-8c47-9a4d36cb629e", _endPointKey);


            var intent = await luisService.GetIntent(question);

            string answer;

            switch (intent)
            {
            case "Group":
                answer = await groupKB.GetAnswer(question);

                break;

            case "Post":
                answer = await postKB.GetAnswer(question);

                break;

            case "None":
                answer = await generalKB.GetAnswer(question);

                break;

            default:
                answer = "Sorry, I don't know that.";
                break;
            }

            if (answer == "")
            {
                answer = "Sorry, I don't know that.";
            }

            var textToSpeechService = new TextToSpeechService();
            var audioAnswer         = await textToSpeechService.GenerateAudioSpeech(answer);

            wrapper.Text  = answer;
            wrapper.Audio = audioAnswer;
            return(wrapper);
        }