private async Task CameraLoadExecute() { LogHelper.Log <WebcamService>("Je me mets au travail!"); await WebcamService.InitializeCameraAsync(); WebcamService.CaptureElement = CaptureElement; await WebcamService.StartCameraPreviewAsync(); if (WebcamService.IsInitialized && await WebcamService.StartFaceDetectionAsync(300)) { WebcamService.FaceDetectionEffect.FaceDetected += OnFaceDetected; } }
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(); }); } }