Exemple #1
0
        static void Main(string[] args)
        {
            var config = new AppConfig().GetConfig();

            string utterance = "what's up?";
            string filePath  = @"C:\Temp\Tricorder\etc\WP_20170520_17_30_04_Rich.jpg";
            var    extension = Path.GetExtension(filePath);

            using (var fileStream = File.Open(filePath, FileMode.Open))
            {
                var storageManager = new Storage(config.StorageConfig);
                var blobUrl        = storageManager.UploadFile(fileStream, extension);
                fileStream.Close();
                fileStream.Dispose();

                var analyzer = new Geordi(config);
                Geordi.AnalysisResult response = analyzer.Analyze(blobUrl, utterance);

                var modem = new Modem(config.ModemConfig);
                modem.ProduceSpeech(response.Result);

                Console.WriteLine(response.Log);

                var blobUri = new Uri(blobUrl);
                storageManager.DeleteFile(blobUri);
            }
            Console.ReadLine();
        }
Exemple #2
0
        private async void btnAnalyze_Click(object sender, RoutedEventArgs e)
        {
            string blobUrl;

            if (!string.IsNullOrWhiteSpace(txtFilePath.Text))
            {
                blobUrl = txtFilePath.Text;
            }
            else
            {
                CameraCaptureUI dialog = new CameraCaptureUI();
                StorageFile     file   = await dialog.CaptureFileAsync(CameraCaptureUIMode.Photo);

                blobUrl = await UploadPicture(file);
            }

            string utterance;

            if (!string.IsNullOrWhiteSpace(txtUtterance.Text))
            {
                utterance = txtUtterance.Text;
            }
            else
            {
                utterance = "what's up?";
            }

            var fileUri     = txtFilePath.Text;
            var bitmapImage = new BitmapImage(new Uri(fileUri, UriKind.Absolute));

            imgPhoto.Source = bitmapImage;

            var analyzer = new Geordi(AppConfiguration);

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

            var modem  = new Modem(AppConfiguration.ModemConfig);
            var result = modem.ProduceSpeech(response.Result);

            Play(result);

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