public async Task ReadHighestEmotion(FaceAPI.FaceAPI.HighestEmotion highestEmotion) { var textToSynthesize = $"I'm {Convert.ToInt16(highestEmotion.maxConfidence * 100)}% sure that this person's emotion is {highestEmotion.maxConfidenceEmotionName}"; await RunOnUIThread(() => MyFaceEmotionReponse.Text = textToSynthesize); var supportedLanguages = SupportedLanguages.Text; await Task.Run(() => SpeakTextAsync(supportedLanguages, textToSynthesize)); }
private async void button_Full_Click(object sender, RoutedEventArgs e) { // STEP 1 - RECOGNIZE SPEECH FROM MICROPHONE INPUT OR FILE SpeechRecognitionResult result = await recognizeSpeechViewModel.RecognizeSpeechAsyncFromFile(audioFilePathPerson); if (result != null) { await RunOnUIThread(() => this.LoadingBar.Visibility = Visibility.Visible); // STEP 2 - GET INTENT BASED ON RECOGNIZED TEXT var intent = await new LUIS.LUIS(subscriptionKey, endpoint).GetLuisIntent(result.Text); await RunOnUIThread(() => { this.MySpeechIntent.Text = $"Intent: '{intent.prediction.topIntent}',"; this.MySpeechIntentScore.Text = $"score: {intent.prediction.topScore:0.##}"; }); // STEP 3 - FIND IMAGE BASED ON RECOGNIZED TEXT await webSearchViewModel.ProcessWebSearchREST(result.Text); if (intent.prediction.topIntent == "PeoplePictures") { // STEP 4 - DETECT FACES IF THERE ARE PEOPLE IN PICTURE IList <DetectedFace> detectedFaces = await faceViewModel.DetectFaces(); if (detectedFaces.Any()) { FaceAPI.FaceAPI.HighestEmotion highestEmotion = faceViewModel.GetHighestEmotion(detectedFaces.First()); // STEP 5 - READ LOUD HIGHEST SCORED EMOTION await synthesizeTextViewModel.ReadHighestEmotion(highestEmotion); } } else { faceViewModel.faceList = null; await RunOnUIThread(() => this.MyFaceEmotionReponse.Text = string.Empty); } await RunOnUIThread(() => this.LoadingBar.Visibility = Visibility.Collapsed); } }