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(); }
private async void btnAnalyze_Click(object sender, RoutedEventArgs e) { var utterance = string.IsNullOrWhiteSpace(txtUtterance.Text) ? "what's up?" : txtUtterance.Text; var analyzer = new Geordi(AppConfiguration); var stream = await picture.OpenAsync(FileAccessMode.Read); Geordi.AnalysisResult response = await analyzer.AnalyzeAsync(stream.AsStream(), utterance); var modem = new Modem(AppConfiguration.ModemConfig); var result = await modem.ProduceSpeechAsync(response.Result); Play(result); txtAnalysisResult.Text = response.Log; }
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); }
static async Task 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"; using (var fileStream = File.Open(filePath, FileMode.Open)) { var analyzer = new Geordi(config); Geordi.AnalysisResult response = await analyzer.AnalyzeAsync(fileStream, utterance); var modem = new Modem(config.ModemConfig); await modem.ProduceSpeechAsync(response.Result); Console.WriteLine(response.Log); } Console.ReadLine(); }
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 = ""; }