private static async Task HandleReadEventsCommandAsync(VoiceCommandServiceConnection connection) { try { ReadRepository ReadRepository = new ReadRepository(); //Genero un mensaje de espera para que el usuario vea var userMessage = new VoiceCommandUserMessage(); userMessage.DisplayMessage = "Buscando eventos próximos .."; userMessage.SpokenMessage = "Buscando eventos próximos "; var response = VoiceCommandResponse.CreateResponse(userMessage); await connection.ReportProgressAsync(response); var today = DateTime.Now.Date; var notices = await ReadRepository.GetNextEvents(); if (notices.Count > 1) { userMessage.SpokenMessage = userMessage.DisplayMessage = $"El dia de hoy se realizan {notices.Count} eventos"; var tile = new VoiceCommandContentTile(); tile.ContentTileType = VoiceCommandContentTileType.TitleOnly; var titleList = new List <VoiceCommandContentTile>(); var count = 0; foreach (var noticeModel in notices) { if (count <= 5) { titleList.Add(new VoiceCommandContentTile { Title = noticeModel.Title.ToString(), ContentTileType = VoiceCommandContentTileType.TitleWithText, TextLine1 = noticeModel.Date.ToString() }); ++count; } } response = VoiceCommandResponse.CreateResponse(userMessage, titleList); await connection.ReportProgressAsync(response); } else { if (notices != null) { userMessage.SpokenMessage = userMessage.DisplayMessage = $"Usted tiene {notices.First().Title} eventos próximos"; response = VoiceCommandResponse.CreateResponse(userMessage); } } await connection.ReportSuccessAsync(response); } catch (Exception ex) { throw; } }
private static async Task HandleReadNamedaysCommandAsync(VoiceCommandServiceConnection connection) { //Genero un mensaje de espera para que el usuario vea var userMessage = new VoiceCommandUserMessage(); userMessage.DisplayMessage = "Los eventos que se realizan el dia de hoy son"; userMessage.SpokenMessage = "Los eventos que se realizan el dia de hoy son"; var response = VoiceCommandResponse.CreateResponse(userMessage); await connection.ReportProgressAsync(response); var today = DateTime.Now.Date; var notices = await ReadResitory.GetNoticesInDay(); if (notices.Count() > 1) { userMessage.SpokenMessage = userMessage.DisplayMessage = $"El dia de hoy se realizan {notices.Count} eventos"; var tile = new VoiceCommandContentTile(); tile.ContentTileType = VoiceCommandContentTileType.TitleOnly; var titleList = new List <VoiceCommandContentTile>(); var count = 0; foreach (var noticeModel in notices) { if (count <= 5) { titleList.Add(new VoiceCommandContentTile { Title = noticeModel.Title.ToString(), ContentTileType = VoiceCommandContentTileType.TitleWithText, TextLine1 = noticeModel.Date }); ++count; } } response = VoiceCommandResponse.CreateResponse(userMessage, titleList); await connection.ReportProgressAsync(response); } else { if (notices != null) { userMessage.SpokenMessage = userMessage.DisplayMessage = $"El evento que se realiza hoy es {notices.First().Title} eventos"; response = VoiceCommandResponse.CreateResponse(userMessage); } } await connection.ReportSuccessAsync(response); }
private async Task QueryBaikeByKeyword(string keyword) { var userProgressMessage = new VoiceCommandUserMessage(); userProgressMessage.DisplayMessage = userProgressMessage.SpokenMessage = $"正在查询{keyword}"; VoiceCommandResponse response = VoiceCommandResponse.CreateResponse(userProgressMessage); await voiceServiceConnection.ReportProgressAsync(response); var userMessage = new VoiceCommandUserMessage(); var data = await QueryBaike.BaiduBaike.QueryByKeyword(keyword); userMessage.DisplayMessage = userMessage.SpokenMessage = data.Summary; VoiceCommandResponse queryResponse = null; if (data.Image != null) { queryResponse = VoiceCommandResponse.CreateResponse(userMessage, new List <VoiceCommandContentTile> { new VoiceCommandContentTile() { Image = data.Image, ContentTileType = data.TileType } }); } else { queryResponse = VoiceCommandResponse.CreateResponse(userMessage); } queryResponse.AppLaunchArgument = keyword; await voiceServiceConnection.ReportSuccessAsync(queryResponse); }
private async Task ShowProgressScreen(string message) { var userProgressMessage = new VoiceCommandUserMessage(); userProgressMessage.DisplayMessage = userProgressMessage.SpokenMessage = message; VoiceCommandResponse response = VoiceCommandResponse.CreateResponse(userProgressMessage); await vcConnection.ReportProgressAsync(response); }
private static async Task AsyncReportProgress(VoiceCommandServiceConnection connection, string spokenMessage, string displayMessage) { var responseMsg = new VoiceCommandUserMessage { SpokenMessage = spokenMessage, DisplayMessage = displayMessage }; var response = VoiceCommandResponse.CreateResponse(responseMsg); await connection.ReportProgressAsync(response); }
private async Task ShowProgressScreen(string LoadingScreen) { var UserProgressMessage = new VoiceCommandUserMessage(); UserProgressMessage.DisplayMessage = UserProgressMessage.SpokenMessage = LoadingScreen; VoiceCommandResponse response = VoiceCommandResponse.CreateResponse(UserProgressMessage); await VoiceServiceConnection.ReportProgressAsync(response); }
private async Task SendProgressState(int i) { var userProgressMessage = new VoiceCommandUserMessage(); userProgressMessage.DisplayMessage = userProgressMessage.SpokenMessage = "Sending Beacons ... " + i; VoiceCommandResponse response = VoiceCommandResponse.CreateResponse(userProgressMessage); await voiceServiceConnection.ReportProgressAsync(response); }
public static async Task showProgressScreen(VoiceCommandServiceConnection voiceServiceConnection, string message) { VoiceCommandUserMessage userProgressMessage = new VoiceCommandUserMessage(); userProgressMessage.DisplayMessage = userProgressMessage.SpokenMessage = message; VoiceCommandResponse response = VoiceCommandResponse.CreateResponse(userProgressMessage); await voiceServiceConnection.ReportProgressAsync(response); return; }
private async Task ShowProgressScreen(string message) { VoiceCommandUserMessage userProgressMessage = new VoiceCommandUserMessage() { DisplayMessage = message, SpokenMessage = message }; VoiceCommandResponse response = VoiceCommandResponse.CreateResponse(userProgressMessage); await voiceServiceConnection.ReportProgressAsync(response); }
public static async Task ShowProgressScreen(VoiceCommandServiceConnection voiceServiceConnection, string message) { var userProgressMessage = new VoiceCommandUserMessage(); userProgressMessage.DisplayMessage = userProgressMessage.SpokenMessage = message; //METHODS TO RESPOND TO CORTANA TO SEND A BASIC MESSAGE VoiceCommandResponse response = VoiceCommandResponse.CreateResponse(userProgressMessage); await voiceServiceConnection.ReportProgressAsync(response); return; }
/// <summary> /// Show a progress screen. These should be posted at least every 5 seconds for a /// long-running operation, such as accessing network resources over a mobile /// carrier network. /// </summary> /// <param name="voiceCommandServiceConnection"></param> /// <param name="message">The message to display, relating to the task being performed.</param> internal static async Task ShowProgressScreen(VoiceCommandServiceConnection voiceCommandServiceConnection, string message) { var userProgressMessage = new VoiceCommandUserMessage { DisplayMessage = message, SpokenMessage = message }; VoiceCommandResponse response = VoiceCommandResponse.CreateResponse(userProgressMessage); await voiceCommandServiceConnection.ReportProgressAsync(response); }
private async Task FindCommandHandleAsync(SpeechRecognitionSemanticInterpretation interpretation) { var searchQuery = string.Empty; if (interpretation.Properties.ContainsKey("DiceNum")) { searchQuery = interpretation.Properties["DiceNum"].FirstOrDefault(); } if (!string.IsNullOrEmpty(searchQuery) && !string.IsNullOrWhiteSpace(searchQuery)) { response = VoiceCommandResponse.CreateResponse(new VoiceCommandUserMessage() { SpokenMessage = "Get ready", DisplayMessage = "Get ready" }); await voiceServiceConn.ReportProgressAsync(response); //await DisambiguateAsync("Select a result", "Please select a result"); var promptStr = "Select a result"; var repromptStr = "Please select a result"; var contentTiles = new List <VoiceCommandContentTile>(); for (var i = 1; i < 7; i++) { var tile = new VoiceCommandContentTile(); tile.ContentTileType = VoiceCommandContentTileType.TitleWith68x68IconAndText; tile.Image = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///ControlPanel.BackgroundServices/Assets/68_Dice_{i}.png")); tile.AppContext = i; tile.AppLaunchArgument = $"type={i}"; tile.Title = $"The dice result is {i}"; contentTiles.Add(tile); } var result = await Helpers.VoiceCommandResponseHelper.RequestDisambiguationAsync(voiceServiceConn, promptStr, repromptStr, contentTiles); if (result != null) { contentTiles.Clear(); contentTiles.Add(result.SelectedItem); var successStr = "You select a dice"; await Helpers.VoiceCommandResponseHelper.ReportSuccessAsync(voiceServiceConn, successStr, successStr, contentTiles); } } }
private static async Task HandleReadNamedaysCommandAsync(VoiceCommandServiceConnection connection) { var userMessage = new VoiceCommandUserMessage(); userMessage.DisplayMessage = "Fetching today's namedays for you"; userMessage.SpokenMessage = "Fetching today's namedays for you"; var response = VoiceCommandResponse.CreateResponse(userMessage); await connection.ReportProgressAsync(response); var today = DateTime.Now.Date; var namedays = await NamedayRepository.GetAllNamedaysAsync(); var todaysNameday = namedays.Find(e => e.Day == today.Day && e.Month == today.Month); var namedaysAsString = todaysNameday.NamesAsString; if (todaysNameday.Names.Count() == 1) { userMessage.SpokenMessage = userMessage.DisplayMessage = $"It is { namedaysAsString}'s nameday today"; response = VoiceCommandResponse.CreateResponse(userMessage); } else { userMessage.SpokenMessage = $"Today's namedays are: {namedaysAsString}"; userMessage.DisplayMessage = "Here are today's namedays:"; var tile = new VoiceCommandContentTile(); tile.ContentTileType = VoiceCommandContentTileType.TitleOnly; tile.Title = namedaysAsString; response = VoiceCommandResponse.CreateResponse(userMessage, new List <VoiceCommandContentTile> { tile }); } await connection.ReportSuccessAsync(response); }
private static async Task HandleReadNamedaysCommandAsync(VoiceCommandServiceConnection connection) { var userMessage = new VoiceCommandUserMessage(); userMessage.DisplayMessage = "Je récupères les noms du jour pour vous"; userMessage.SpokenMessage = "Je récupères les noms du jour pour vous"; var response = VoiceCommandResponse.CreateResponse(userMessage); await connection.ReportProgressAsync(response); var today = DateTime.Now.Date; var namedays = await NamedayRepository.GetAllNamedaysAsync(); var todaysNamedays = namedays.Find(e => e.Day == today.Day && e.Month == today.Month); var namedaysAsString = todaysNamedays.NamesAsString; if (todaysNamedays.Names.Count() == 1) { userMessage.SpokenMessage = userMessage.DisplayMessage = $"Le nom du jour est {namedaysAsString}"; response = VoiceCommandResponse.CreateResponse(userMessage); } else { userMessage.SpokenMessage = $"Les noms du jour sont {namedaysAsString}"; userMessage.DisplayMessage = "Voici les noms du jour : "; var tile = new VoiceCommandContentTile(); tile.ContentTileType = VoiceCommandContentTileType.TitleOnly; tile.Title = namedaysAsString; response = VoiceCommandResponse.CreateResponse(userMessage, new List <VoiceCommandContentTile> { tile }); } await connection.ReportSuccessAsync(response); }
private static async Task HandleReadNamedaysCommandAsync(VoiceCommandServiceConnection connection) { var userMessage = new VoiceCommandUserMessage(); userMessage.DisplayMessage = "Fetching today's namedays for you"; userMessage.SpokenMessage = "Fetching today's namedays for you"; var response = VoiceCommandResponse.CreateResponse(userMessage); await connection.ReportProgressAsync(response); var today = DateTime.Now.Date; var namedays = await NamedayRepository.GetAllNamedaysAsync(); var todaysNameday = namedays.Find(e => e.Day == today.Day && e.Month == today.Month); var namedaysAsString = todaysNameday.NamesAsString; if (todaysNameday.Names.Count() == 1) { userMessage.SpokenMessage = userMessage.DisplayMessage = $"It is {namedaysAsString}'s nameday today"; response = VoiceCommandResponse.CreateResponse(userMessage); } else { userMessage.SpokenMessage = $"Today's namedays are: {namedaysAsString}"; userMessage.DisplayMessage = "Here are today's namedays:"; var tile = new VoiceCommandContentTile(); tile.ContentTileType = VoiceCommandContentTileType.TitleOnly; tile.Title = namedaysAsString; response = VoiceCommandResponse.CreateResponse(userMessage, new List<VoiceCommandContentTile> { tile }); } await connection.ReportSuccessAsync(response); }
/// <summary> /// /// </summary> /// <param name="connection"></param> /// <returns></returns> private static async Task HandleReadImageLabelsCommandAsync(VoiceCommandServiceConnection connection) { //Initialize some stuff var CaptureClient = new CameraCaptureService.CameraCaptureService(); await CaptureClient.Init(); ///var GoogleVisionClient = new GoogleVisionAPI.VisionClient(); var MicrosoftVisionClient = new MicrosoftCognitiveVisionRepository.MicrosoftCognitiveVisionClient(); //Tell the user that we are doing something var userMessage = new VoiceCommandUserMessage(); userMessage.DisplayMessage = "Analyzing your surroundings"; userMessage.SpokenMessage = "Analyzing"; var response = VoiceCommandResponse.CreateResponse(userMessage); await connection.ReportProgressAsync(response); //TODO: Get the image string imageString; try { imageString = await CaptureClient.Capture(); } catch (Exception) { userMessage.DisplayMessage = "I can't access the camera, try opening up the Identify app first"; userMessage.SpokenMessage = "No Camera. Try opening Identify first, then ask me again."; response = VoiceCommandResponse.CreateResponse(userMessage); await connection.ReportFailureAsync(response); return; } //TODO: Send the Image through the Vision Client ///List<string> googleAnnotationResponse; string microsoftAnnotationResponse; try { //Use Google ///googleAnnotationResponse = await GoogleVisionClient.Run(imageString); //Use Microsoft microsoftAnnotationResponse = await MicrosoftVisionClient.Run(imageString); } catch (Exception) { userMessage.DisplayMessage = "Try checking your connection"; userMessage.SpokenMessage = "Hmm... I can't get a response from the cloud."; response = VoiceCommandResponse.CreateResponse(userMessage); await connection.ReportFailureAsync(response); return; } //var finalResponse = string.Join(", ", googleAnnotationResponse); var finalResponse = microsoftAnnotationResponse; //TODO: Set the User Message, Display & Spoken userMessage.DisplayMessage = finalResponse; userMessage.SpokenMessage = finalResponse; response = VoiceCommandResponse.CreateResponse(userMessage); await connection.ReportSuccessAsync(response); }
private async Task ReportProgress(string message, VoiceCommandServiceConnection voiceCommandServiceConnection) { var response = this.CreateResponse(message); await voiceCommandServiceConnection.ReportProgressAsync(response); }
public async void Run(IBackgroundTaskInstance taskInstance) { AppServiceTriggerDetails triggerDetails = taskInstance.TriggerDetails as AppServiceTriggerDetails; if (triggerDetails != null && triggerDetails.Name == "VoiceCommandService") { m_VoiceServiceDeferral = taskInstance.GetDeferral(); taskInstance.Canceled += VoiceTaskInstance_Canceled; if (triggerDetails.CallerPackageFamilyName == cortanaFamilyId) { // Being called from Cortana m_VoiceServiceConnection = VoiceCommandServiceConnection.FromAppServiceTriggerDetails(triggerDetails); m_VoiceServiceConnection.VoiceCommandCompleted += VoiceServiceConnection_VoiceCommandCompleted; // GetVoiceCommandAsync establishes initial connection to Cortana, and must be called prior to any // messages sent to Cortana. Attempting to use ReportSuccessAsync, ReportProgressAsync, etc // prior to calling this will produce undefined behavior. VoiceCommand voiceCommand = await m_VoiceServiceConnection.GetVoiceCommandAsync(); switch (voiceCommand.CommandName) { case "setLightsOn": var onProgressResponse = VoiceCommandResponse.CreateResponse(new VoiceCommandUserMessage() { DisplayMessage = "Turning all lights on", SpokenMessage = "Turning all lights on" }); await m_VoiceServiceConnection.ReportProgressAsync(onProgressResponse); if (await g_CommandHandler.SetAllOnAsync()) { // All operations succeeded var successCommandResponse = VoiceCommandResponse.CreateResponse(new VoiceCommandUserMessage() { DisplayMessage = "All lights on", SpokenMessage = "All lights on" }); await m_VoiceServiceConnection.ReportSuccessAsync(successCommandResponse); await NotifyAppOnStateChange(true); } else { var failureCommandResponse = VoiceCommandResponse.CreateResponse(new VoiceCommandUserMessage() { DisplayMessage = "Failed to turn all lights on", SpokenMessage = "Something went wrong. Could not turn all lights on" }); await m_VoiceServiceConnection.ReportFailureAsync(failureCommandResponse); } break; case "setLightsOff": var offProgressResponse = VoiceCommandResponse.CreateResponse(new VoiceCommandUserMessage() { DisplayMessage = "Turning all lights off", SpokenMessage = "Turning all lights off" }); await m_VoiceServiceConnection.ReportProgressAsync(offProgressResponse); if (await g_CommandHandler.SetAllOnAsync()) { // All operations succeeded var successCommandResponse = VoiceCommandResponse.CreateResponse(new VoiceCommandUserMessage() { DisplayMessage = "All lights off", SpokenMessage = "All lights off" }); await m_VoiceServiceConnection.ReportSuccessAsync(successCommandResponse); await NotifyAppOnStateChange(false); } else { var failureCommandResponse = VoiceCommandResponse.CreateResponse(new VoiceCommandUserMessage() { DisplayMessage = "Failed to turn all lights off", SpokenMessage = "Something went wrong. Could not turn all lights off" }); await m_VoiceServiceConnection.ReportFailureAsync(failureCommandResponse); } break; } } if (triggerDetails.CallerPackageFamilyName == Windows.ApplicationModel.Package.Current.Id.FamilyName) { // Being called from the foreground application m_AppServiceDeferral = taskInstance.GetDeferral(); taskInstance.Canceled += AppServiceTask_Canceled; triggerDetails.AppServiceConnection.ServiceClosed += AppServiceConnection_ServiceClosed; g_AppServiceConnection = triggerDetails.AppServiceConnection; } } }
public async void Run(IBackgroundTaskInstance taskInstance) { //Take a service deferral so the service isn't terminated. this.serviceDeferral = taskInstance.GetDeferral(); var triggerDetails = taskInstance.TriggerDetails as AppServiceTriggerDetails; if (triggerDetails != null && triggerDetails.Name == "BookReaderVoiceCommandService") { try { voiceServiceConnection = VoiceCommandServiceConnection.FromAppServiceTriggerDetails(triggerDetails); voiceServiceConnection.VoiceCommandCompleted += VoiceCommandCompleted; VoiceCommand voiceCommand = await voiceServiceConnection.GetVoiceCommandAsync(); switch (voiceCommand.CommandName) { case "deleteBook": { var userMessage = new VoiceCommandUserMessage(); userMessage.DisplayMessage = "Deleting book"; userMessage.SpokenMessage = "Deleting Book"; var progressReport = VoiceCommandResponse.CreateResponse(userMessage); await voiceServiceConnection.ReportProgressAsync(progressReport); var book = voiceCommand.Properties["bookName"][0]; userMessage = new VoiceCommandUserMessage(); userMessage.DisplayMessage = book + "deleted"; userMessage.SpokenMessage = "File deleted"; try { var folder = ApplicationData.Current.LocalFolder; var subFolder = await folder.GetFolderAsync("books"); var a = await folder.GetFolderAsync(book + ".txt"); var b = await subFolder.GetFileAsync(book + ".txt"); await a.DeleteAsync(); await b.DeleteAsync(); updateBookPhrases(); await voiceServiceConnection.ReportSuccessAsync(VoiceCommandResponse.CreateResponse(userMessage)); } catch (Exception) { userMessage.DisplayMessage = "Something went wrong, " + book + " not deleted"; userMessage.SpokenMessage = "Something went wrong, File not deleted"; await voiceServiceConnection.ReportFailureAsync(VoiceCommandResponse.CreateResponse(userMessage)); } break; } } } finally { if (this.serviceDeferral != null) { // Complete the service deferral. this.serviceDeferral.Complete(); } } } }
public async void Run(IBackgroundTaskInstance taskInstance) { //Service deferral to prevent service termination this.serviceDeferral = taskInstance.GetDeferral(); var triggerDetails = taskInstance.TriggerDetails as AppServiceTriggerDetails; if (triggerDetails != null && triggerDetails.Name == "MediaPlayerVoiceCommandService") { try { voiceServiceConnection = VoiceCommandServiceConnection.FromAppServiceTriggerDetails(triggerDetails); voiceServiceConnection.VoiceCommandCompleted += VoiceCommandCompleted; /* Note: these background commands don't do anything interesting and are simply here to demonstrate * that commands can be run in the background using Cortana as part of this project. It is possible * to add commands relevant to this application such as playing a song in the background however * it's not practical since Cortana must provide progress every 5 seconds and besides the user can * give a command to play a song and simply minimize the app and the song continues to play while * the app is in the suspended state. */ VoiceCommand voiceCommand = await voiceServiceConnection.GetVoiceCommandAsync(); switch (voiceCommand.CommandName) { case "backgroundTask": { var userMessage = new VoiceCommandUserMessage(); userMessage.DisplayMessage = "Processing your request"; userMessage.SpokenMessage = "Processing your request"; var progressReport = VoiceCommandResponse.CreateResponse(userMessage); await voiceServiceConnection.ReportProgressAsync(progressReport); try { userMessage = new VoiceCommandUserMessage(); userMessage.DisplayMessage = "Executing your request"; userMessage.SpokenMessage = "Executing your request"; await voiceServiceConnection.ReportSuccessAsync(VoiceCommandResponse.CreateResponse(userMessage)); } catch (Exception) { userMessage.DisplayMessage = "Something went wrong, terminating process"; userMessage.SpokenMessage = "Something went wrong, terminating process"; await voiceServiceConnection.ReportFailureAsync(VoiceCommandResponse.CreateResponse(userMessage)); } break; } case "backgroundTask2": { var userMessage = new VoiceCommandUserMessage(); userMessage.DisplayMessage = "Processing your request"; userMessage.SpokenMessage = "Processing your request"; var progressReport = VoiceCommandResponse.CreateResponse(userMessage); await voiceServiceConnection.ReportProgressAsync(progressReport); try { userMessage = new VoiceCommandUserMessage(); userMessage.DisplayMessage = "Executing your request"; userMessage.SpokenMessage = "Executing your request"; await voiceServiceConnection.ReportSuccessAsync(VoiceCommandResponse.CreateResponse(userMessage)); } catch (Exception) { userMessage.DisplayMessage = "Something went wrong, terminating process"; userMessage.SpokenMessage = "Something went wrong, terminating process"; await voiceServiceConnection.ReportFailureAsync(VoiceCommandResponse.CreateResponse(userMessage)); } break; } } } finally { if (this.serviceDeferral != null) { //Complete the service deferral this.serviceDeferral.Complete(); } } } }
public async void Run(IBackgroundTaskInstance taskInstance) { m_Deferral = taskInstance.GetDeferral(); AppServiceTriggerDetails triggerDetails = taskInstance.TriggerDetails as AppServiceTriggerDetails; if (triggerDetails != null && triggerDetails.Name == "VoiceCommandService") { taskInstance.Canceled += VoiceTaskInstance_Canceled; if (triggerDetails.CallerPackageFamilyName == cortanaFamilyId) { // Being called from Cortana m_VoiceServiceConnection = VoiceCommandServiceConnection.FromAppServiceTriggerDetails(triggerDetails); m_VoiceServiceConnection.VoiceCommandCompleted += VoiceServiceConnection_VoiceCommandCompleted; // GetVoiceCommandAsync establishes initial connection to Cortana, and must be called prior to any // messages sent to Cortana. Attempting to use ReportSuccessAsync, ReportProgressAsync, etc // prior to calling this will produce undefined behavior. VoiceCommand voiceCommand = await m_VoiceServiceConnection.GetVoiceCommandAsync(); switch (voiceCommand.CommandName) { case "open": var onProgressResponse = VoiceCommandResponse.CreateResponse(new VoiceCommandUserMessage() { DisplayMessage = "Opening all shades", SpokenMessage = "Please wait until I open all shades" }); await m_VoiceServiceConnection.ReportProgressAsync(onProgressResponse); if (await g_CommandHandler.OpenAllAsync()) { // All operations succeeded var successCommandResponse = VoiceCommandResponse.CreateResponse(new VoiceCommandUserMessage() { DisplayMessage = "Shades are now open", SpokenMessage = "Shades are now open" }); await m_VoiceServiceConnection.ReportSuccessAsync(successCommandResponse); } else { var failureCommandResponse = VoiceCommandResponse.CreateResponse(new VoiceCommandUserMessage() { DisplayMessage = "Failed to open the shades", SpokenMessage = "Something went wrong. Could not open all shades" }); await m_VoiceServiceConnection.ReportFailureAsync(failureCommandResponse); } break; case "close": var offProgressResponse = VoiceCommandResponse.CreateResponse(new VoiceCommandUserMessage() { DisplayMessage = "Closing shades", SpokenMessage = "Please wait until I close all shades" }); await m_VoiceServiceConnection.ReportProgressAsync(offProgressResponse); if (await g_CommandHandler.CloseAllAsync()) { // All operations succeeded var successCommandResponse = VoiceCommandResponse.CreateResponse(new VoiceCommandUserMessage() { DisplayMessage = "Shades are closed", SpokenMessage = "Shades are now closed" }); await m_VoiceServiceConnection.ReportSuccessAsync(successCommandResponse); } else { var failureCommandResponse = VoiceCommandResponse.CreateResponse(new VoiceCommandUserMessage() { DisplayMessage = "Failed to close all shades", SpokenMessage = "Something went wrong. Could not close all shades" }); await m_VoiceServiceConnection.ReportFailureAsync(failureCommandResponse); } break; } } } }