예제 #1
0
        public string ProduceSpeechTextItalian(ImageAnalysis imageAnalysis)
        {
            var resultBuilder = new StringBuilder();

            if (imageAnalysis.Faces.Count == 0)
            {
                resultBuilder.Append("Non vedo persone");
            }
            else if (imageAnalysis.Faces.Count == 1)
            {
                var face = imageAnalysis.Faces.First();
                resultBuilder.Append(face.Gender == Gender.Female ? "C'è una donna" : "C'è un uomo");
                resultBuilder.Append($" che sembra avere { face.Age} anni");
            }
            else
            {
                resultBuilder.Append($"Ci sono {imageAnalysis.Faces.Count} persone. Più precisamente: ");
                foreach (var face in imageAnalysis.Faces)
                {
                    resultBuilder.Append(face.Gender == Gender.Female ? "una donna" : "un uomo");
                    resultBuilder.Append($" che sembra avere {face.Age} anni, ");
                }
                resultBuilder.Append("."); //a little hack
            }
            var ssml = Modem.BuildSsmlAsync(resultBuilder.ToString(), "it").Result;

            return(ssml);
        }
예제 #2
0
        public string ProduceSpeechTextEnglish(ImageAnalysis imageAnalysis)
        {
            var resultBuilder = new StringBuilder();

            if (imageAnalysis.Faces.Count == 0)
            {
                resultBuilder.Append("There are no people around");
            }
            else if (imageAnalysis.Faces.Count == 1)
            {
                var face = imageAnalysis.Faces.First();
                resultBuilder.Append($"There is one {face.Gender} person of age {face.Age}.");
            }
            else
            {
                resultBuilder.Append($"There are {imageAnalysis.Faces.Count} people around. More in detail: ");
                foreach (var face in imageAnalysis.Faces)
                {
                    resultBuilder.Append($"a {face.Gender} of age {face.Age}, ");
                }
                resultBuilder.Append("."); //a little hack
            }
            var ssml = Modem.BuildSsmlAsync(resultBuilder.ToString(), "en").Result;

            return(ssml);
        }
예제 #3
0
        private async void btnListen_Click(object sender, RoutedEventArgs e)
        {
            bool permissionGained = await AudioCapturePermissions.RequestMicrophonePermission();

            if (!permissionGained)
            {
                var ssml = await Modem.BuildSsmlAsync("Could not enable the microphone, please try again.", "en");

                var modem  = new Modem(AppConfiguration.ModemConfig);
                var speech = await modem.ProduceSpeechAsync(ssml);

                Play(speech);
            }
            else
            {
                txtUtterance.Text = "(listening...)";
                var modem     = new Modem(AppConfiguration.ModemConfig);
                var utterance = await modem.ListenAsync();

                switch (utterance.Item1)
                {
                case ResultReason.RecognizedSpeech:
                    txtUtterance.Text = utterance.Item2;
                    break;

                case ResultReason.NoMatch:
                default:
                    txtUtterance.Text = "";
                    var ssml = await Modem.BuildSsmlAsync("Could not understand utterance, please try again.", "en");

                    var speech = await modem.ProduceSpeechAsync(ssml);

                    Play(speech);
                    break;
                }
            }
        }
예제 #4
0
        private async void btnAnalyze_Click(object sender, RoutedEventArgs e)
        {
            var modem = new Modem(AppConfiguration.ModemConfig);

            if (string.IsNullOrWhiteSpace(txtFilePath.Text))
            {
                var ssml = await Modem.BuildSsmlAsync("Please, either upload or take a new picture.", "en");

                var speech = await modem.ProduceSpeechAsync(ssml);

                Play(speech);
            }
            if (string.IsNullOrWhiteSpace(txtUtterance.Text))
            {
                txtUtterance.Text = "what's up?";
            }

            string blobUrl   = txtFilePath.Text;
            var    utterance = txtUtterance.Text;

            var bitmapImage = new BitmapImage(new Uri(blobUrl, UriKind.Absolute));

            imgPhoto.Source = bitmapImage;

            var analyzer = new Geordi(AppConfiguration);

            Geordi.AnalysisResult response = await analyzer.AnalyzeAsync(blobUrl, utterance);

            var result = await modem.ProduceSpeechAsync(response.Result);

            Play(result);

            txtAnalysisResult.Text = response.Log;
            DeletePicture(blobUrl);

            txtFilePath.Text = "";
        }
예제 #5
0
        public string ProduceSpeechTextItalian(ImageAnalysis imageAnalysis)
        {
            var ssml = Modem.BuildSsmlAsync(imageAnalysis.Description.Captions.First().Text, "it").Result;

            return(ssml);
        }