protected override async Task OnLoadedAsync() { await RunTaskAsync(async() => { EventList = await EventsLoaderService.GetEventsJsonAsync(10); }) .ContinueWith(async task => { if (!task.IsFaulted) { await VoiceInterface.SayEventsAvailable(); } await VoiceInterface.ListeningCancellation(); Messenger.Default.Register <SpeechResultGeneratedMessage>(this, async e => { if (e.Result.Constraint.Tag == "constraint_abord_words") { if (e.Result.Text.Contains("au-revoir") || e.Result.Text.Contains("bonne journée")) { await DispatcherHelper.RunAsync(async() => await GoBackToMainExecute()); } else { await DispatcherHelper.RunAsync(async() => await GoBackToMenuExecute()); } } }); }); }
protected override async Task OnLoadedAsync() { List <Carousel> ListCarousel = new List <Carousel>(); await RunTaskAsync(async() => { string _carousel; foreach (Attachment attachment in Attachments) { _carousel = JsonConvert.SerializeObject(attachment.Content); ListCarousel.Add(JsonConvert.DeserializeObject <Carousel>(_carousel)); } await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { CarouselList = ListCarousel; } ); }) .ContinueWith(async task => { await VoiceInterface.ListeningCancellation(); Messenger.Default.Register <SpeechResultGeneratedMessage>(this, async e => { if (e.Result.Constraint.Tag == "constraint_abord_words") { await DispatcherHelper.RunAsync(async() => await GoBackToMainExecute()); } }); }); }
private async Task GoBackToMenuExecute() { // Cleans up services and messenger await VoiceInterface.StopListening(); Messenger.Default.Unregister(this); NavigationService.NavigateTo(ViewModelLocator.MenuPage, CurrentPerson); }
public async Task CallSomeoneExecute() { await RunTaskAsync(async() => { await VoiceInterface.StopListening(); await VoiceInterface.SayNotAvailableService(); await VoiceInterface.ListeningWhatToDo(); }); }
// General actions public async Task DescribeExecute() { await RunTaskAsync(async() => { await VoiceInterface.StopListening(); await VoiceInterface.SayDescriptionOfSomeone(CurrentPerson); await VoiceInterface.ListeningWhatToDo(); }); }
public async Task GoToReservationPageExecute() { await RunTaskAsync(async() => { await VoiceInterface.StopListening(); await VoiceInterface.SayNotAvailableService(); await VoiceInterface.ListeningWhatToDo(); }); }
// Navigations public async Task GoToEventPageExecute() { await RunTaskAsync(async() => { await VoiceInterface.StopListening(); Messenger.Default.Unregister(this); NavigationService.NavigateTo(ViewModelLocator.EventPage, CurrentPerson); }); }
public async Task GoToCarouselPageExecute(IList <Attachment> attachments) { await RunTaskAsync(async() => { await VoiceInterface.StopListening(); Messenger.Default.Unregister(this); NavigationService.NavigateTo(ViewModelLocator.CarouselPage, attachments); }); }
public async Task GoBackToMainPageExecute() { await RunTaskAsync(async() => { await VoiceInterface.StopListening(); await VoiceInterface.SayGoodBye(); Messenger.Default.Unregister(this); NavigationService.NavigateTo(ViewModelLocator.MainPage); }); }
// Navigation actions private async Task GoBackToMainExecute() { // Cleans up services and messenger await VoiceInterface.StopListening(); await VoiceInterface.SayGoodBye(); Messenger.Default.Unregister(this); NavigationService.NavigateTo(ViewModelLocator.MainPage); }
// Navigations public async Task GoToMenuPage(PersonDto person) { // Clean up services and messenger await VoiceInterface.StopListening(); await WebcamService.CleanUpAsync(); Messenger.Default.Unregister(this); NavigationService.NavigateTo(ViewModelLocator.MenuPage, person); }
private async void OnFaceDetected(FaceDetectionEffect sender, FaceDetectedEventArgs args) { if (!IsLoading && args.ResultFrame.DetectedFaces.Any()) { await DispatcherHelper.RunAsync(async() => { await RunTaskAsync(async() => { var persons = await MakeRecognition(); await VoiceInterface.SayHelloAsync(persons); }); }); } }
private async Task SolicitExecute() { if (WebcamService.FaceDetectionEffect != null) { await WebcamService.StopFaceDetectionAsync(); } LogHelper.Log("Que puis-je faire pour toi?"); await TtsService.SayAsync("Que puis-je faire pour toi?"); var str = await VoiceInterface.Listen(); LogHelper.Log(str); var activity = new Activity { From = new ChannelAccount("Jean"), Text = str, Type = ActivityTypes.Message }; if (activity.Text == "") { await TtsService.SayAsync("au revoir"); connection.OnMessage -= Connection_OnMessage; if (WebcamService.FaceDetectionEffect != null) { await WebcamService.StopFaceDetectionAsync(); } if (WebcamService.IsInitialized && await WebcamService.StartFaceDetectionAsync(300)) { WebcamService.FaceDetectionEffect.FaceDetected += OnFaceDetected; } await VoiceInterface.ListeningHelloAda(); } else { activity.Text = (activity.Text).Replace('.', ' '); activity.Text = (activity.Text).ToLower(); await _client.Conversations.PostActivityAsync(_conversation.ConversationId, activity); } }
private async void HandleActivity(Activity activity) { var text = WebUtility.HtmlDecode(activity.Text); var attachments = activity.Attachments; if (attachments?.Count > 0) { var token = new CancellationTokenSource(); await VoiceInterface.StopListening(); await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { await WebcamService.CleanUpAsync(); await GoToCarouselPageExecute(attachments); } ); } LogHelper.Log(text); await TtsService.SayAsync(text); if (activity.Name == "End") { connection.OnMessage -= Connection_OnMessage; if (WebcamService.FaceDetectionEffect != null) { await WebcamService.StopFaceDetectionAsync(); } if (WebcamService.IsInitialized && await WebcamService.StartFaceDetectionAsync(300)) { WebcamService.FaceDetectionEffect.FaceDetected += OnFaceDetected; } await VoiceInterface.ListeningHelloAda(); } else if (activity.Name != "NotFinish") { await DispatcherHelper.RunAsync(async() => { await SolicitExecute(); }); } }
protected override async Task OnLoadedAsync() { await VoiceInterface.ListeningWhatToDo(); Messenger.Default.Register <SpeechResultGeneratedMessage>(this, async e => { await DispatcherHelper.RunAsync(async() => { switch (e.Result.Constraint.Tag) { case "constraint_events": await GoToEventPageExecute(); break; case "constraint_description": await DescribeExecute(); break; case "constraint_abord_words": await GoBackToMainPageExecute(); break; case "constraint_sandwich": await GoToSandwichPageExecute(); break; case "constraint_calling": await CallSomeoneExecute(); break; case "constraint_reservation": await GoToReservationPageExecute(); break; } }); }); }
protected override async Task OnLoadedAsync() { await Task.Run(() => { while (!_isDirectLineInitialized) { } }); connection.OnMessage += Connection_OnMessage; // Registers to messenger for on screen log messages Messenger.Default.Register <LogMessage>(this, async e => await DispatcherHelper.RunAsync(() => LogMessage += e.Message)); // Begins to listening "hello ada" await VoiceInterface.ListeningHelloAda(); // Registers to messenger to catch messages when a speech recognition result // was generated Messenger.Default.Register <SpeechResultGeneratedMessage>(this, async e => { if (e.Result.Constraint.Tag == "constraint_hello_ada") { if (VoiceInterface != null) { await VoiceInterface.StopListening(); } LogHelper.Log("Message reçu ;)"); LogHelper.Log("Je suis à toi dans un instant"); await TtsService.SayAsync("Message reçu, je suis à toi dans un instant"); PersonDto person = null; if (WebcamService.FaceDetectionEffect != null) { await WebcamService.StopFaceDetectionAsync(); person = (await MakeRecognition())?.FirstOrDefault(); } if (person != null) { PersonUpdateDto updateDto = new PersonUpdateDto { PersonId = person.PersonId, RecognitionId = person.RecognitionId }; await VoiceInterface.SayHelloAsync(person); // Update person's name if (person.FirstName == null) { string answer = await VoiceInterface.AskIdentified(); if (answer != "non") { string name = await VoiceInterface.AskNameAsync(); if (name == null) { return; } updateDto.FirstName = name; person.FirstName = name; AdaClient client = new AdaClient() { WebAppUrl = AppConfig.WebUri }; await client.PutPerson(updateDto); } } } else { await TtsService.SayAsync("Bonjour"); } await DispatcherHelper.RunAsync(async() => { await SolicitExecute(); }); } }); //// Prepares capture element to camera feed and load camera CaptureElement = new CaptureElement(); await CameraLoadExecute(); }